
Chapter 4: Learning Just Enough C# and VB.NET: Intermediate Syntax | 93 |
Console.ReadKey()
End Sub
Public Event OverDraft As EventHandler
Public Sub AccountOverdraft (ByVal sender As Object, ByVal e As EventArgs)
Console.WriteLine("Overdraft Occurred") End Sub
End Module
Listing
Look at the set accessor of the CurrentBalance property, inside of the if statement where it determines if value is less than 0. The C# example has another if statement to see if the OverDraft event is equal to null.
In C# when an event is equal to null, it means that nothing has subscribed to be notified by the
In VB, you don’t need to check for Nothing (equivalent to C# null).
The preceding discussion talked about a method that is hooked up to the event and executes (receives a message) whenever the event fires. The next section explains how to use a delegate to specify what this method is.