AddressOf Operator


AddressOf Operator

Syntax

     AddressOf procedureName 


procedureName (required)

The name of a procedure or method to be referenced as a delegate

Description

The AddressOf operator returns a procedure delegate instance that references a specific procedure. Common uses of this operator include the following:

  • To bind event handlers to events through the AddHandler statement:

         AddHandler Form1.Click, AddressOf Me.Form1_Click 

  • To create delegate objects, as in:

         Dim holdDelegate As Delegate = _        New Delegate(AddressOf someClass.SomeMethod) 

  • To pass the address of a callback function to a Win32 API function:

         Call TypicalAPI(1, AddressOf MyCallbackRoutine) 

Version Differences

In VB 6, the procedure must reside in a standard code module, a restriction no longer enforced with .NET.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

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