McBasic™Get McBasic™ ↗
Build 881
Components · Nonvisual component
Timer component icon

Timer

Separate a checkbox activation from its stored Boolean value.

2 properties1 events0 methodsDefault: Timer

Use it in a Form#

Click describes activation, while Change describes a value transition. The clock’s running state must follow the checkbox value rather than toggling an unrelated flag each time. Keep timer handlers short and update the display from the current clock value.

Add Timer to the component tray and name it Timer1 for this example:

PropertyExample value
EnabledFalse
Interval1000

A complete handler from Forms/frmMain.bas. The linked lesson includes its surrounding controls, declarations and helpers.

Forms/frmMain.bas
Private Sub Timer1_Timer()
    lblLabel1.Caption = Format(Now, "HH:mm:ss")
End Sub

Properties#

Contract defaults are shown below. Where a new control has a different Designer starting value, that value is listed separately.

Interval

LongDefault: 1000

Time between Timer events in milliseconds. 0 disables the timer: no Timer event while Interval is 0, whatever Enabled is. Events run on the UI thread.

Range: 0 to 2147483647.

Enabled

BooleanDefault: False

Starts or stops Timer events. The timer stops when its form unloads.

Events and parameters#

Replace control with the object’s Name when creating a handler. ByRef arguments may be changed by your handler; ByVal arguments report an input value.

Timer

Occurs on the UI dispatcher after each enabled timer interval.

Signature — see the complete lesson for an implementation
Private Sub control_Timer()

No parameters.

Methods#

No methods are declared in this component’s built-in metadata. Use its documented properties and events; do not infer APIs from a similarly named control in another framework.

Source baseline 20f4bfed6b · Build manifest