Sunday, May 31, 2009

Delay in Visual Basic

Call Pause(ParamDelay) ' delay for 30 seconds

Sub Pause(ByVal nSecond As Single)
Dim t0 As Single
Dim dummy As Integer

t0 = Timer

Do While Timer - t0 < nSecond
'cursormove = "."
'Application.StatusBar = "Update Status " & countstat & " %" & cursormove

dummy = DoEvents()

' If we cross midnight, back up one day
If Timer < t0 Then
t0 = t0 - 24 * 60 * 60 ' or t0 = t0 - 86400

End If

cursormove = " ."
Application.StatusBar = "Update Status " & countstat & cursormove
Loop

End Sub

' Call the routine from the appropriate event:
' Example:

'Call Pause(30) ' delay for 30 seconds
'Form2.Show

No comments:

Post a Comment