PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Wait in VB-VBForums
Results 1 to 9 of 9

Thread: Wait in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    4

    Wait in VB

    Hi All,

    I am looking for a wait function in VB. To tell you some details, I am using VB functions for MS EXcel to run some automated scripts. Now, I want a function in VB which would WAIT(time) for the time specified. Anyone has any idea, how can I use that??

  2. #2
    Addicted Member Xiphias3's Avatar
    Join Date
    Jan 2009
    Location
    Clarendon, Jamaica
    Posts
    188

    Re: Wait in VB

    What kind of "WAIT"?
    Complete Freeze or Semi-Freeze.

    Complete Freeze:
    vb Code:
    1. Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    2.  
    3. Ex; Call Sleep(1000) ' Freeze app for 1 second. Makes the app unresponsive

    Semi-Freeze
    Looping while Processing Message pump for messages like Redraw, Click, etc

    vb Code:
    1. Do While (bSuccess == False)
    2.     DoEvents ' Readraw Form, respond to clicks, etc
    3. Loop

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    4

    Re: Wait in VB

    Quote Originally Posted by Xiphias3 View Post
    What kind of "WAIT"?
    Complete Freeze or Semi-Freeze.

    Complete Freeze:
    vb Code:
    1. Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    2.  
    3. Ex; Call Sleep(1000) ' Freeze app for 1 second. Makes the app unresponsive

    Semi-Freeze
    Looping while Processing Message pump for messages like Redraw, Click, etc

    vb Code:
    1. Do While (bSuccess == False)
    2.     DoEvents ' Readraw Form, respond to clicks, etc
    3. Loop

    I think, I would need a complete freeze. As, I want my execution to stop for a specified amount of time, and the begin again.
    So, the complete freeze u mentioned would allow me to specifiy the amount of time?
    Thanx a lot :-)

  4. #4
    Addicted Member Xiphias3's Avatar
    Join Date
    Jan 2009
    Location
    Clarendon, Jamaica
    Posts
    188

    Re: Wait in VB

    The Sleep function takes 1 argument, time in milliseconds.
    1000 = 1 Second
    vb Code:
    1. Call Sleep(5000) ' Sleep for 5 seconds

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    4

    Re: Wait in VB

    Quote Originally Posted by Xiphias3 View Post
    The Sleep function takes 1 argument, time in milliseconds.
    1000 = 1 Second
    vb Code:
    1. Call Sleep(5000) ' Sleep for 5 seconds
    Cool, thats good. Let me check out whether it satisfies my issue. Thanx.!! have a nice day.

  6. #6
    Addicted Member Xiphias3's Avatar
    Join Date
    Jan 2009
    Location
    Clarendon, Jamaica
    Posts
    188

    Re: Wait in VB

    Just remember, the app becomes unresponsive with Sleep(). if you're gonna use it, place a DoEvents after the Sleep() so the application can process the pending events like Redraw.

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    4

    Re: Wait in VB

    Quote Originally Posted by Xiphias3 View Post
    Just remember, the app becomes unresponsive with Sleep(). if you're gonna use it, place a DoEvents after the Sleep() so the application can process the pending events like Redraw.
    Yeah Ok, need to do that !!

  8. #8
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Wait in VB

    The Sleep API should be avoided like the plague unless you use it in minuscule slices. Here's how I use it. The example shows how it's called.

    http://www.vbforums.com/showpost.php...12&postcount=8
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  9. #9
    Addicted Member ZenDisaster's Avatar
    Join Date
    Dec 2006
    Location
    Bay Area, CA
    Posts
    140

    Re: Wait in VB

    If you're going to use a busy waiting loop, use the one in the link provided by CDRIVE as it is not as likely to turn your processor into molten silicon.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width