Wednesday, August 25, 2010

Simple Timer

Simple Timer
The timer object is quite simple to use. It is an invisible object that runs in the background of a form. The timer has one event, a timer event occurs every time the time interval expires.

For example if you set the timer interal to 1000(1 second), then every second a timer event will occur. You can code what happens when the timer event is triggered, just make sure the timers enabled property is set to true.

For Example:
Define a variable in the form-
Dim clock as integer

Place the following code in the timer event
clock=clock+1
label1.text=clock

You could add two buttons, one to start the timer and one to stop the timer. Starting the timer would involve setting the "clock" variable to 0 and the timer enabled property to true. Stop the timer simply involves setting the timer enabled property to false.

No comments:

Post a Comment