<pre id=\\\"best-answer-content\\\">Use the Timer control for longer than 1 minute
As you know, the Timer control provides a great way to schedule events in a Visual Basic project. When you enable the control, it fires off its Timer event every n milliseconds, as determined by the TimeInterval property. However, the TimeInterval property only accepts numbers up to 65,535, or just over one minute. As a result, you may have wondered how to use this control for periods longer than that. To do so, use a form, or project level, variable to keep track of how many times the Timer event fires. Then, in the Timer event, re-enable the control if enough time hasn注释:t passed. For example, consider the code below that we attached to a standard form.
Option Explicit
Dim iElapsedMin As Integer
Const cMax_Min As Integer = 2
Private Sub Form_Load()
Timer1.Enabled = True
iElapsedMin = 1
End Sub
Private Sub Timer1_Timer()
lblText.Visible = (iElapsedMin = cMax_Min)
Timer1.Enabled = (iElapsedMincMax_Min)
iElapsedMin = iElapsedMin 1
End Sub
|