Delegate Sub EventHandler()
Event _show As EventHandler
' Use AddHandler to attach two EventHandlers to Event.AddHandler _show, New EventHandler(AddressOf Important1)
AddHandler _show, New EventHandler(AddressOf Important2)
' Use RaiseEvent to run all handlers for this event.RaiseEvent _show()
' Do something important.
' Do something else that is also important.
With Events, a single entry point can invoke many methods. This is powerful. But in VB.NET we usually use Events in Windows Forms or WPF programs. Events help with GUI development.
Note In a GUI a button click will cause an event to be raised. We can run any number of methods when a click occurs.
RemoveHandler. This does the opposite of AddHandler. We can remove methods from the internal event handler list of an Event. This keyword is used less often.
WithEvents. Another syntax form can be used to add events in VB.NET. We can use the WithEvents keyword and the Handles keyword on event-handlers.