Timer Event -- Event Procedures

Description

To create an event procedure that is executed when the Timer event occurs, set the OnTimer property to [Event Procedure], and click the Build button.

Syntax

Private Sub Form_Timer( )

Remarks

You can’t cancel the Timer event.

See Also

Timer Event — Macros.

Example

The following example demonstrates a digital clock you can display on a form. A label control displays the current time according to your computer’s system clock.

To try this example, add the following code to the Declarations section of a module for a form that contains a label named Clock. Set the form’s TimerInterval property to 1000 milliseconds to update the clock every second.


Private Sub Form_Timer()
    Clock.Caption = Time            ' Update time display.Sub