In the event handle, because of the Handler, the previous function name is not important,
Private sub buttonx1_click (Byval e as system.Object, byval e as system.eventargs) Handles Button1.Click MSGBOX ("hi") End Sub
versus
Private sub button1_click (byvale as system.Object, byval e as system.eventargs) Handles Button1.Click Msgbox ("hi") End Sub
no difference.
In addition, the processing function is outside the definition of the class, and it is for the object, not class.
Module Module1
Public class chenry
Public Event EventHR () 'Declaration an event
Sub causesomeevent ()
RaiseEvent Eventhr () 'triggered events
End Sub
END CLASS
WitHevents Obj AS New CHENRY 'Module or Class Declaration Sub Obj_Eventhr () Handles Obj.Eventhr
MsgBox ("Event Processor Captures Events.") 'Handling Events.
End Sub
Sub main ()
Obj.causesomeevent () 'calls the object to trigger the event
End Sub
End module
My understanding:
1. Event processing functions can be outside the class containing events, and must be outside
2, the event handler is an object that belongs to an object, of course this object is an object that contains the class of this event.
3, the above object must be declared with the WitHevents declaration
4. Events that follow the object after Handler in the event handler