CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Wait or Pause

  1. #1
    Join Date
    Apr 2001
    Posts
    51

    Wait or Pause

    Is there a command pause until something is finished before proceeding to the next command.
    I would want to execute a sub and then wait for about 5 seconds then execute another sub.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Wait or Pause

    You can use the Sleep() API function as follows


    private Declare Sub Sleep Lib "kernel32" (byval dwMilliseconds as Long)
    private Sub Command1_Click()
    MsgBox "First one"
    Sleep 5000
    MsgBox "Second One"
    End Sub





  3. #3
    Join Date
    Apr 2001
    Posts
    51

    Re: Wait or Pause

    I should have more specific. Will this work in VB 6.0?


  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Wait or Pause

    Yes. It pauses for the number of milliseconds specified.


  5. #5
    Join Date
    Apr 2000
    Posts
    737

    Re: Wait or Pause

    you can use Sleep API if u want to wait for specific time. However, if u want to wait for certain event to happen, for instance, in communication programming (comm port), if u want to wait for 5 bytes in the receiving buffer, then u will need to use WaitForSingleObject.

    HTH

    cksiow
    http://vblib.virtualave.net - share our codes


  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Wait or Pause

    I am afraid this will freeze your program for 5 seconds. So, if you have timers on it, they will be paused, too...

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured