WithEvents

In VB.Net the WithEvents keyword
You can declare an object variable using the keyword WithEvents to allow the events from that class to be captured.

WithEvents objButton As System.Windows.Forms.Button 

You must create an instance of this class first.

objMyButton = New System.Windows.Forms.Button 

You can then declare a procedure with the Handles keyword to associate this with a particular event.

Public Sub MyButtonClick(byVal sender As Object, _ 
                           ByVal s As System.EventArgs) Handles objMyButton.Click
End Sub

You cannot create arrays of WithEvents object varaibles.



© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext