Wait command for Visual Basic 6
Wait command for Visual Basic 6
(OP)
Hello
Someone knows any command that keep the program waiting for a few miliseconds, without using the timer control?
I need this to put between two calls
Call function1(a,b,c)
***** Here is the wait ****
Call function2(a,b,c)
Thanks a lot
Someone knows any command that keep the program waiting for a few miliseconds, without using the timer control?
I need this to put between two calls
Call function1(a,b,c)
***** Here is the wait ****
Call function2(a,b,c)
Thanks a lot
RE: Wait command for Visual Basic 6
In a module, you have to declare
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub wait(ByVal dblMilliseconds As Double)
Dim dblStart As Double
Dim dblEnd As Double
Dim dblTickCount As Double
dblTickCount = GetTickCount()
dblStart = GetTickCount()
dblEnd = GetTickCount + dblMilliseconds
Do
DoEvents
dblTickCount = GetTickCount()
Loop Until dblTickCount > dblEnd Or dblTickCount < dblStart
End Sub
all what you kave to do now is to call wait(num), when num in the amount of miliseconds that the program waits to continue in the next line.
I hope this help to the rest of you.
RE: Wait command for Visual Basic 6
Declare Sub Sleep Lib "kernel32" (ByVal milliseconds As Long)
' pause for 5 seconds
Sleep 5000
Remember...
"If you don't use your head,
your going to have to use your feet."
RE: Wait command for Visual Basic 6
So if you want to wait for a few seconds, and not have the program do anything during that time, then Sleep is fine.
On the other hand, if your time delay is allow some other routine in your program sufficient time to complete its task, then Sleep will not work, because the other routine that you're waiting on, will also be sleeping.