Pause

Make your program pause for a given number of seconds. Works across midnight.

Paste the following into a module:

Public Sub Pause(ByVal pSng_Secs As Single) 
'Wait for the number of seconds given by pSng_Secs 
Dim lSng_Start As Single 
Dim lSng_End As Single 
On Error GoTo Err_Pause 
    lSng_Start = Timer 
    lSng_End = Timer + pSng_Secs 
    Do While Timer < lSng_End 
    '' Correction if the timer moves over to a new day (midnight)
    '' 86400-num of secs in a day 
        If Timer < lSng_Start Then lSng_End = lSng_End - 86400 
    Loop 
Err_Pause: 
    Exit Sub 
End Sub 

To test this procedure, use the following routine.

Sub TestPause() 
    Pause 2 
    MsgBox "Hi" 
End Sub 

Published: 15-May-2004
Last edited: 01-Mar-2011 20:51