Changes

Jump to: navigation, search

Understanding Visual Basic Events

19 bytes added, 18:14, 17 July 2007
Setting Up a Visual Basic Timer Event
At the beginning of this chapter we mentioned that objects can trigger their own events. So far we have only looked at events triggered by user interaction with the application's user interface. We will now look at configuring the ''Timer'' object to trigger its own events. The first step is to add a ''Timer'' object to our application. First, display the Toolbox if it is not already visible, unfold the ''Components'' section of the Toolbox list and scroll down until you find the ''Timer'' object. To add a ''Timer'' to the application simply double click on it. Because the Timer is not a visible object it appears in a special area beneath the Form as shown in the following figure:
[[Image:Examplvisual_basic_timer_object.jpg]]
With the ''Timer'' object selected, use the ''Properties'' panel to change the ''Enabled'' property to ''True'' and the ''Interval'' property to ''10000''. Next double click on the ''Timer'' object to edit the event procedure. The ''Timer'' object has a single event, the ''Tick'' event, which is triggered each time the timer interval elapses. We are going to write code to set the myLabel control to display ''Your time is up'' when the ''Tick'' event triggers:

Navigation menu