Creating Custom Events - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8) +----- Forum: Code Snippets (https://bpforums.info/forumdisplay.php?fid=18) +----- Thread: Creating Custom Events (/showthread.php?tid=504) |
Creating Custom Events - brandonio21 - 04-03-2012 This code snippet was made after hours of work on my project QuickClean To make a custom event, the first thing you are going to do is declare the event for global usage in the global declarations section of your class. For example, Code: Public Class Modes Then, in order to call this event, you must use the code snippet RaiseEvent So, using our same example: Code: Public Class Modes Now, every time the SwitchMode method is called, the event onModeSwitch will be called. This event can now be accessed in the code viewer on any new instance of this class. Re: Creating Custom Events - Vinwarez - 04-04-2012 I think I get it, but I will ask anyway. So whenever in the code you type SwitchMode() the message box, with the smiley, will appear? Sorry for being lazy-ass, it's pretty late. Oh, and you will be online soon. Re: Creating Custom Events - brandonio21 - 04-04-2012 No, actually, that will not occur. This is how you would use it! Code: Public Sub MS() Handles Modes1.onModeSwitch() Re: Creating Custom Events - Vinwarez - 04-05-2012 brandonio21 Wrote:No, actually, that will not occur. This is how you would use it!Okay. Thanks. I think this might be useful for my current project. |