Dim WithEvents StockInfoEventHandler As StockInfo
What does the WithEvents mean? Can someone explain what this does and what it is used for and why? Thank you.
Printable View
Dim WithEvents StockInfoEventHandler As StockInfo
What does the WithEvents mean? Can someone explain what this does and what it is used for and why? Thank you.
From MSDN:So when you declare something WithEvents then you can handle events with it in this wayQuote:
The WithEvents keyword allows you to create class or module-level object variables that can be used with the Handles clause in event handlers.
VB Code:
Sub myevent(event arguments goes here) Handles myobject.Event some code here End Sub
Yeah, it basically exposes all the events of one object to the caller so you can catch and deal with those events that are raised.
the withevents keyword has a slight performance hit in that ALL events will exposed/fired whether you want to catch them or not...well it was that way at least in VB6