Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating Custom Events
#1
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

    Event onModeSwitch()

'Sample method
Public Sub New()
   Msgbox(":D")
End Sub
End Class

Then, in order to call this event, you must use the code snippet RaiseEvent

So, using our same example:
Code:
Public Class Modes

    Event onModeSwitch()

'Sample method
Public Sub New()
   Msgbox(":D")
End Sub

'Sample Method to Raise Event
Public Sub SwitchMode()
  RaiseEvent onModeSwitch()
End Sub
End Class

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.
My Blog | My Setup | My Videos | Have a wonderful day.
#2
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.
Also known as Rocketalypse.
System.out.println("I prefer Java.");
#3
No, actually, that will not occur. This is how you would use it!
Code:
Public Sub MS() Handles Modes1.onModeSwitch()
Msgbox("Hello, world!")
End Sub
So then every time the SwitchMode() method is called, the hello world messagebox will appear!
My Blog | My Setup | My Videos | Have a wonderful day.
#4
brandonio21 Wrote:No, actually, that will not occur. This is how you would use it!
Code:
Public Sub MS() Handles Modes1.onModeSwitch()
Msgbox("Hello, world!")
End Sub
So then every time the SwitchMode() method is called, the hello world messagebox will appear!
Okay. Thanks. I think this might be useful for my current project.
Also known as Rocketalypse.
System.out.println("I prefer Java.");


Forum Jump:


Users browsing this thread: 1 Guest(s)