Permalink
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (60 sloc) 2.32 KB
title ms.date ms.prod ms.reviewer ms.suite ms.technology ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author translation.priority.ht
AddHandler Statement
2015-07-20
.net
devlang-visual-basic
article
vb.AddHandlerMethod
addhandler
vb.addhandler
VB
AddHandler statement
cfe69799-2a0f-42c0-a99e-09fed954da01
15
dotnet-bot
dotnetcontent
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

AddHandler Statement

Associates an event with an event handler at run time.

Syntax

AddHandler event, AddressOf eventhandler  

Parts

event
The name of the event to handle.

eventhandler
The name of a procedure that handles the event.

Remarks

The AddHandler and RemoveHandler statements allow you to start and stop event handling at any time during program execution.

The signature of the eventhandler procedure must match the signature of the event event.

The Handles keyword and the AddHandler statement both allow you to specify that particular procedures handle particular events, but there are differences. The AddHandler statement connects procedures to events at run time. Use the Handles keyword when defining a procedure to specify that it handles a particular event. For more information, see Handles.

[!NOTE] For custom events, the AddHandler statement invokes the event's AddHandler accessor. For more information on custom events, see Event Statement.

Example

[!code-vbVbVbalrEvents#17]

See Also

RemoveHandler Statement
Handles
Event Statement
Events