Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait command for Visual Basic 6 1

Status
Not open for further replies.

efighettib

Structural
Jan 13, 2004
26
CL
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
 
Replies continue below

Recommended for you

After a long wait, I solved this problem on my own.

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.
 
This is easier:

Declare Sub Sleep Lib &quot;kernel32&quot; (ByVal milliseconds As Long)
' pause for 5 seconds
Sleep 5000




Remember...
&quot;If you don't use your head,
your going to have to use your feet.&quot;
 
One thing to note about the Sleep command, is that it suspends all processing for that process while it's sleeping.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top