Is there a command pause until something is finished before proceeding to the next command.
I would want to execute a sub and then wait for about 5 seconds then execute another sub.
Printable View
Is there a command pause until something is finished before proceeding to the next command.
I would want to execute a sub and then wait for about 5 seconds then execute another sub.
You can use the Sleep() API function as follows
private Declare Sub Sleep Lib "kernel32" (byval dwMilliseconds as Long)
private Sub Command1_Click()
MsgBox "First one"
Sleep 5000
MsgBox "Second One"
End Sub
I should have more specific. Will this work in VB 6.0?
Yes. It pauses for the number of milliseconds specified.
you can use Sleep API if u want to wait for specific time. However, if u want to wait for certain event to happen, for instance, in communication programming (comm port), if u want to wait for 5 bytes in the receiving buffer, then u will need to use WaitForSingleObject.
HTH
cksiow
http://vblib.virtualave.net - share our codes
I am afraid this will freeze your program for 5 seconds. So, if you have timers on it, they will be paused, too...
Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.