Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 2.13 KB

File metadata and controls

54 lines (44 loc) · 2.13 KB
title AddHandler Statement
ms.date 07/20/2015
ms.prod .net
ms.reviewer
ms.suite
ms.technology
devlang-visual-basic
ms.topic article
f1_keywords
vb.AddHandlerMethod
addhandler
vb.addhandler
helpviewer_keywords
AddHandler statement [Visual Basic]
ms.assetid cfe69799-2a0f-42c0-a99e-09fed954da01
caps.latest.revision 15
author dotnet-bot
ms.author dotnetcontent

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