Hi
How to use Sleep Function In VB?? Any help on this?
thanks in advance
Karthik K
Printable View
Hi
How to use Sleep Function In VB?? Any help on this?
thanks in advance
Karthik K
You just need to declare the API call as such...
and implement it in this way..Code:Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
It's as simple as that, you just have to be careful using the Sleep function in your apps because while it is 'sleeping' you will not be able to performs other events and such until it is completed and it may cause your application to be recognized as being idle (thanks Chris ;))Code:Sleep 500 ' Causes application to stop for 500 milliseconds
Hi
Thanks for the help. But how to use that Seconds..I mean I cant add more number of Zeros ..
Karthik
Thanks
Not quite sure what you are asking but 1000 milliseconds is equal to 1 second.Code:
Sleep 1000 ' equal to 1 second
If you want a second-based (not millisecond-based) delay, that doesn't freeze your application while it's delaying: :rolleyes:
To use:Code:Sub Delay(ByVal nSeconds As Single)
Dim nStart As Single
nStart = Timer
Do
DoEvents
Loop Until Timer - nStart >= nSeconds
End Sub
Code:Call Delay(17) ' Wait 17 seconds
Call Delay(1.5) ' Wait 1 second + 500 milliseconds
' etc.