What can we use as an equivalent to "Sleep()" in vb?

S

StargateFan

I searched through the archives and there were a few messages
discussing this but no actual syntax could be found (at least during 2
searches).

Is there any vb equivalent to "Sleep()"?

Thanks. :blush:D
 
R

RB Smissaert

Use the Sleep API:

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)

Sub TestingSleep()

Sleep 2000
Cells(1) = 1

End Sub


RBS
 
E

Equiangular

Do you mean this?

Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Sub test()
Msgbox "Wait for 1 sec"
Sleep 1000
Msgbox "Done"
End Sub
 
B

Bob Phillips

Two ways


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

Sub WaitSeconds()
Sleep 1000 * 3 ' 3 seconds
End Sub


and


Sub WaitFor()
Application.Wait Now + TimeSerial(0, 0, 3) ' 3 seconds
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
S

StargateFanFromWork

Bob Phillips said:
Two ways


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

Sub WaitSeconds()
Sleep 1000 * 3 ' 3 seconds
End Sub


and


Sub WaitFor()
Application.Wait Now + TimeSerial(0, 0, 3) ' 3 seconds
End Sub

Thanks to everyone for their responses! :blush:D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top