Results 1 to 7 of 7

Thread: Wait until done executing...

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    51

    Post

    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).]

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318

    Post

    I can't get your questoin, what do you mean by process, another exe program, or control's event?

  3. #3
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    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).]

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    51

    Post

    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

  5. #5
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Post

    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

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    51

    Post

    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!

  7. #7
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width