Home > Language Reference > Classes
Timer Class
+ Object
+ Timer
Description
The Timer class implements the necessary functionality to raise an event at regular intervals. This class is instantiable but not derivable or cloneable.
To use this object, instantiate it, set the time interval required between events using the Interval property then activate the timer using the Enabled property. From this moment Timer events are raised. The following example which should be copied onto a form containing a Label control shows how this works :
Private tm as New Timer Private iCount as Integer Private Sub Form_Load() tm.Interval = 500 tm.Enabled = True End Sub Private Sub Form_Unload() tm.Enabled = False End Sub Private Sub tm_Timer() iCount = iCount + 1 Label1.Caption = iCount End Sub
You can access different properties of this class when you handle the Timer event. The following example which should be copied onto a form containing a Button control shows how to create a one shot timer :
Private tm as New Timer Private Sub Button1_Click() tm.Interval = 1000 tm.Enabled = True End Sub Private Sub tm_Timer() tm.Enabled = False MsgBox "One shot timer" End Sub
Note that to correctly receive events raised by a Timer object, its Recipient property should be correctly initialized. Refer to the documentation of this property for further information.
Members
| Members | Description |
| Enabled | Indicates if a Timer object is active or not. |
| Interval | Number of milliseconds between two events. |
| Timer | Occurs when the preset interval has elapsed. |
| Inherited from Object | Description |
| ClassID | Returns the type identifier corresponding to the actual class of the object. |
| Implements | Determines whether the object implements the features of a given class. |
| Iterate | Event raised to iterate over the elements of a container object. |
| Recipient | Recipient of events sent by the object. |
| Serialize | Event raised to serialize the object content into a stream. |
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |