See Also Example
Applies To
Timer.
Description
Determines the number of milliseconds
Usage
[form.]timer.Interval[ = milliseconds ]
Setting
The Interval property settings are:
Setting Description
0 (Default) Disables a timer.
1 to 65,535 Sets an interval (in milliseconds) that takes effect when a timer control's Enabled property is set to True. Specify a long integer in this range. For example, a value of 10,000 milliseconds equals 10 seconds. The maximum, 65,535 milliseconds, is equivalent to just over one minute.
Remarks
You can set a timer control's Interval property at design time or run time. When using the Interval property, remember:
The timer control's Enabled property determines whether the timer control responds to the passage of time. Set Enabled to False to turn the timer off, and to True to turn it on. When a timer is enabled, its countdown always starts from the value of its Interval property setting.
Write a Timer event procedure to tell Visual Basic what to do each time the Interval has passed.
Note There are a limited number of timers available (16 in the Windows environment). Trying to start a timer if none is available causes a run-time error .
Data Type
Long
Programmer's Guide:
Chapter 17, "Interacting with the Environment"
The example allows you to adjust the speed at which a form switches colors. To try this example, paste the code into the Declarations section of a form that contains a timer, a horizontal scroll bar, and a picture box. Then press F5 and click the scroll bar.
Sub Form_Load ()
Timer1.Interval = 900 ' Set interval.
HScroll1.Min = 100 ' Set minimum.
HScroll1.Max = 900 ' Set maximum.
End Sub
Sub HScroll1_Change ()
' Set interval according to scroll bar value.
Timer1.Interval = 1000 - HScroll1.Value
End Sub
Sub Timer1_Timer ()
' Switch BackColor between Red and Blue.
If Picture1.BackColor = RGB(255, 0, 0) Then
Picture1.BackColor = RGB(0, 0, 255)
Else
Picture1.BackColor = RGB(255, 0, 0)
End If
End Sub