How to Program a Delay Using the Timer FunctionID: Q96069
|
You can delay execution of your code for a specific time interval by using
the Timer function.
With Visual Basic for MS-DOS, you cannot use the SLEEP statement to do this
while forms are showing. An attempt to do so causes this error:
Invalid when forms are showing.
Sub Form_Click ()
Print "hello ";
Call Pause(2) ' delay for 2 seconds
Print "world"
End Sub
Sub Pause (ByVal nSecond As Single)
Dim t0 As Single
t0 = Timer
Do While Timer - t0 < nSecond
Dim dummy As Integer
dummy = DoEvents()
' if we cross midnight, back up one day
If Timer < t0 Then
t0 = t0 - clng(24) * clng(60) * clng(60)
End If
Loop
End Sub
Additional query words: B_VBasic B_VBMSDOS 1.00 2.00 3.00 wait
Keywords :
Version : WINDOWS:2.0,3.0
Platform : WINDOWS
Issue type :
Last Reviewed: May 25, 1999