PDA

Click to See Complete Forum and Search --> : Wait until done executing...


desquite
Jan 12th, 2000, 04:05 AM
How can I tell vb to wait until the computer finished the first process until it moves to the next step? My program runs faster than the computer can handle. Each step is executed and then the computer has to catch up. I need it to do each step one at a time. Any ideas?

Thanks

[This message has been edited by desquite (edited 01-12-2000).]

kmchong
Jan 12th, 2000, 10:03 AM
I can't get your questoin, what do you mean by process, another exe program, or control's event?

Al Smith
Jan 12th, 2000, 10:25 AM
If you're sending instructions to another application, e.g. sendkeys, try putting a DoEvents command after the command. The program won't continue until the event is completed.
If you're "Shelling" a command, try the tip below,

http://www.vb-world.net/tips/tip5.html
Al.


------------------
A computer is a tool, not a toy.
<A HREF="mailto:asmith3914@aol.com
asmith@spxateg.com">asmith3914@aol.com
asmith@spxateg.com</A>



[This message has been edited by Al Smith (edited 01-12-2000).]

desquite
Jan 12th, 2000, 10:01 PM
I'm sorry I wasn't specific. It's actually my lines of code that I'm talking about. I want the first line of code to execute, then wait until computer finishes processing it before it moves to the next line of code. I've put a few pauses with DoEvents in there but it's very unconsistant depending on how fast your computer is.

Thanks

JazzBass
Jan 13th, 2000, 11:35 AM
Hi desquite,
I had to do the same thing in an app that I wrote. I would run some DOS batch commands and the code would keep running all the batch commands at once. This is what I did.

I used the findwindow api in a loop to look for the dos window. If the window was there, then it would keep checking for the dos window until it was gone. When it was gone, then it would move to the next line of code.

Try the following line after the last line of code in your process:
sFinished = "Yes"


Then have a loop like this:
Do
If sFinished = "Yes" Then
Exit Do
Else
End If
DoEvents
Loop

When it finds that sFinished is equal to "Yes", it will exit the loop and proceed.

Let us know what you use :)
JazzBass

------------------
21 yr old beginner VB Programmer
VB 6 Professional @ Home
VB 3 Professional @ the Office

desquite
Jan 13th, 2000, 11:43 AM
Thanks JazzBass. Funny thing...I just did that right before you sent the message. I check for the windows and wait until they're gone.

Thanks!

JazzBass
Jan 13th, 2000, 11:52 AM
desquite,
Good deal! I meant to ask you if you had any open windows running in your process, but I figured you'd get the idea if that was the case.
Glad to be of help.
JazzBass