How to delay the processing for seconds

accesser2003

Registered User.
Local time
Today, 04:59
Joined
Jun 2, 2007
Messages
124
Is there any function to delay the system processing for a number of seconds.

For the time being I am do it indirectly by using loops, however, it is un proper way, as it is not scalable.

Also I dont want to use the timer control.

Thanks,
 
Is there any function to delay the system processing for a number of seconds.
Possibly
Also I dont want to use the timer control.
Why? To limit your options doesn't make sense. Have you had some sort of negative experience with the timer?

So, what are you trying to actually do? What you are trying to do may determine what is the best way of doing it.
 
The API call Roy is talking about works like a charm. It so happens that I couldn't remember that thing when I needed it and stumbled across this post almost on accident. It's just one line of code (and one line each time you want to use it) and it performs what you want with no need for a timer event.
 
Create the function
Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Err_Pause

Dim PauseTime As Variant, Start As Variant

PauseTime = NumberOfSeconds
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop

Exit_Pause:
Exit Function

Err_Pause:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Pause

End Function

Then in your code at the point you want to pause
Pause (2)' where 2 is the number of seconds to pause.

HTH
 

Users who are viewing this thread

Back
Top Bottom