Delay (sleep, wait, pause)

Posted on August 9th, 2008 in VB. NET Functions by Terp

This code allows you to pause your script, and allows it to do other stuff either than stop the entire app like sleep does:

Sub Delay(ByVal dblSecs As Double)

Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
Dim dblWaitTil As Date
Now.AddSeconds(OneSec)
dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
Do Until Now > dblWaitTil
Application.DoEvents()
Loop

End Sub

Post a comment