Sub Wait(dblSeconds As Double)
'To use Wait(10)
Dim I As Double
For I = 1 To dblSeconds * 100
DoEvents ' handle events
Sleep (10) ' suspend process without a performance hit
Next
End Sub
Public Function Pause(dblInterval As Double)
Dim Start As Double
Start = Timer
Do While Timer < Start + interval
Loop
End Function
I had a different situation than @kitty77 if you're interested.Kitty77, I won't say this NEVER makes sense - but can you tell us WHY you want that delay?
'###############################################
#If VBA7 Then 'A2010 or later (32/64-bit)
Declare PtrSafe Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
#Else 'A2007 or earlier
Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
#End If
'###############################################
Sub Wait(N As Integer)
'creates a delay while other code executes
'N = number of seconds to wait
Dim i As Integer
For i = 1 To N
Sleep 1000 'sleep function from api library file
Next
DoEvents
End Sub
MsgBox "Serial Number is " & txtTheSerialNumber, vbOKOnly, "Press ENTER to continue"
Then there is another question - how many times does a user have to click OK after each entered record before they retaliate by placing a thumb tack upside down on your desk chair?The question in my mind is whether 3 seconds is enough to see anything or too long or just right.
Public Function Pause(dblInterval As Double) Dim Start As Double Start = Timer Do While Timer < Start + interval Loop End Function
Public Function Pause(dblInterval As Double)
Dim Start As Double
Start = Timer
Do While Timer < Start + interval
DoEvents 'Pass control to the processor to finish other waiting tasks in queue
Loop
End Function