Click to See Complete Forum and Search --> : Wait or Pause
mevasquez
April 29th, 2001, 12:07 PM
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.
shree
April 29th, 2001, 12:41 PM
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
mevasquez
April 29th, 2001, 12:54 PM
I should have more specific. Will this work in VB 6.0?
shree
April 29th, 2001, 12:59 PM
Yes. It pauses for the number of milliseconds specified.
cksiow
April 29th, 2001, 09:00 PM
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
Cimperiali
April 30th, 2001, 05:23 AM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.