AddHandler Statement

   
AddHandler Statement

Syntax

 AddHandler   NameOfEventSender   , AddressOf   NameOfEventHandler   
NameOfEventSender (required; String literal)

The name of a class or object instance and its event, such as Button1.Click

NameOfEventHandler (required; 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.

  • NameOfEventSender takes the form class.event or object.event.

  • You can stop handling events defined by the AddHandler statement by calling the RemoveHandler statement.

Example

For an illustration, see Section 7.2.3 in Chapter 7.

Programming Tips and Gotchas

The Handles 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.

See Also

RemoveHandler Statement

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net