Name
AddHandler Statement
Syntax
AddHandlerNameOfEventSender, AddressOfNameOfEventHandler
-
NameOfEventSender Use: Required
Type: String literal
The name of a class or object instance and its event, such as Button1.Click
-
NameOfEventHandler Use: Required
Type: String literal
The name of a subroutine that is to serve as the event handler for
NameOfEventSender
Description
Binds an event handler to a built-in or custom event. This makes it possible to bind several event handlers to a single event.
EventNameOfSendertakes the formclass.eventorobject.event.You can stop handling events defined by the
AddHandlerstatement by calling theRemoveHandlerstatement.
Example
For an illustration, see Section 6.2.3 in Chapter 6.
Programming Tips and Gotchas
The WithEvents keyword can be used to receive
event notification for the lifetime of an object. In contrast,
AddHandler and RemoveHandler
can be used to dynamically add and remove event notification at
runtime.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access