Pauses an operation while allowing other operations to run. This pause is date and time based. The sleep function freezes your computer. The timer function and timer controls stop at midnight because they return to a 0 value. The perfect pause continues where these stop. It’s highly configurable.
Original Author: rbennett
Inputs
‘Seconds are inputed as seconds ( 1 = 1sec). A boolean is inputed for a quick ‘exit, and an integer of 0 or 1 are inputted to determine the type of return.
Assumptions
‘it is assumed the user knows a small bit about programming and function calls ‘within modules. It is assumed the users computer is keeping good time
Returns
‘Returns a boolean
Code
'=========================
'Paste in a BAS module
'=========================
Option Explicit
Public exitPause As Boolean
Public Function timedPause(secs As Long)
Dim secStart As Variant
Dim secNow As Variant
Dim secDiff As Variant
Dim Temp%
exitPause = False 'this is our early way out out of the pause
secStart = Format(Now(), "mm/dd/yyyy hh:nn:ss AM/PM") 'get the starting seconds
Do While secDiff < secs
If exitPause = True Then Exit Do
secNow = Format(Now(), "mm/dd/yyyy hh:nn:ss AM/PM") 'this is the current time and date at any itteration of the loop
secDiff = DateDiff("s", secStart, secNow) 'this compares the start time with the current time
Temp% = DoEvents
Loop
End Function
'=============================
'Paste in a form with 1 command button
'=============================
Option Explicit
Private Sub Command1_Click()
timedPause 25
MsgBox "Time is up buddy!"
End Sub