VB.NET•Create Events the Easy Way

Listing 2. Create events (calling them like methods) and pass parameters by using the Event modifier before a method name. Creating events lets you fire specific methods at predetermined times during your code's execution.

' This event is raised back to the calling 
' thread to set properties on the 
' progress bar
Public Event UpdateProgress _
   (ByVal CurrentCount As Integer, _
   ByVal DatabaseCount As Integer)

' This event is raised back to the secondary
' thread created to invoke the update on the 
' TreeView control
Public Event AddNode _
   (ByVal CurrentNode As TreeNode, _
   ByVal ParentNode As TreeNode, _
   ByVal ChildNode As TreeNode)