Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause Execution 1

Status
Not open for further replies.

gamechampionx

Programmer
Jan 26, 2002
14
0
0
CA
Is there a way to pause execution for a given amount of milliseconds, like pause(10) or something similar?
 
Try:

Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)


Usage:

Sleep 10 'to sleep for ten milliseconds

Sleep 1000'to sleep for a second... Troy Williams B.Eng.
fenris@hotmail.com

 
How do I use this? Could you explain the syntax? I can't get it to work! Where do you writh the Sleep 10 or whatever?
 
Alternately, you could use this sub...
Sub Pause(Seconds) 'to use pause(1000) for 1 second
Dim PauseTime, Start
PauseTime = Seconds ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + Seconds
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
End Sub

Although in my opinion the api call fenris showed you
is better
Dragnut
 
Declare the code below in a module or at the top of a form:

Public Declare Sub Sleep Lib &quot;kernel32&quot; Alias &quot;Sleep&quot; (ByVal dwMilliseconds As Long)




To use the function:

for i = 1 to 10
sleep 10000 'pause execution for 10000 milliseconds = 10 seconds
next i
Troy Williams B.Eng.
fenris@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top