Timer Event — Event Procedures

Description

To create an event procedure that runs 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 the example, add the following event procedure to 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.
End Sub