O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Raising Events

The code sample that follows for event handling routines shows generally how you wire events to certain procedures. The section in bold, for example, consumes an event from a class instance that is not even part of .NET Framework—we created this class specifically to demonstrate how classes trigger events.

Here’s the relevant class code (in AlarmTrigger.vb):

Public Class SimpleAlarmTrigger

    Private WithEvents myTrigger As Timer
    Private myAlarmTime As Date
    Private myAlarmActivated As Boolean
    Private myThreshold As Integer = 2

    ''' <summary>
    ''' Is triggered when a certain time has been reached.
    ''' </summary>
    ''' <param name="Sender">The object which triggered this event.</param>
    ''' <param name="e">AlarmEventArgs which give more information ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required