Results 1 to 8 of 8

Thread: When need "DoEvents" and/or "Sleep"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    When need "DoEvents" and/or "Sleep"

    I have question:

    When need "DoEvents" or "Sleep"

    any advice if this example, need "DoEvents" ?

    Code:
    Private Sub Command1_Click()
    Dim a As Integer
    Dim b As Integer
    Dim c As Integer
    Dim d As Integer
    
    a = 6
    b = 7
    
    c = a + b
    DoEvents
    
    d = c * c
    DoEvents
    
    MsgBox d
    
    
    
    End Sub

  2. #2
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: When need "DoEvents" and/or "Sleep"

    no need for this code
    read this to know abt DoEvents
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2009
    Posts
    492

    Re: When need "DoEvents" and/or "Sleep"

    I was read. but general , open/read/write file. database ado connect. use some OCX (WebBrowser1" that
    need "DoEvents" no else ?

    Also, "DoEvents" is avaible set TIMEOUT ?
    if WebBrowser1 no any response after 60sec,
    open/read/write file/database too large, over 100MB, and still use 60sec
    kill it, msgbox "error"

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: When need "DoEvents" and/or "Sleep"

    link may be useful for u.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


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

    Re: When need "DoEvents" and/or "Sleep"

    Not sure what you're asking but the purpose of DoEvents is not to create a pause/delay. If you're looking for a method of inserting a pause the Sleep API (as a stand alone function) sucks. Without additional code, Sleep will make your app comatose.

    The WaitMessage API is a far better choice. It --needs DoEvents to function though.
    Last edited by CDRIVE; Jun 18th, 2011 at 11:01 AM. Reason: fool annoying advertising link
    <--- 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??

  6. #6
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: When need "DoEvents" and/or "Sleep"

    Rpool

    If you truly want a "sleep" or "wait", as an alternative to CDrive's
    suggestion, check out RhinoBull's snippet in this thread (post #2):

    http://www.vbforums.com/showthread.php?t=652682

    Spoo

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

    Re: When need "DoEvents" and/or "Sleep"

    Quote Originally Posted by Spoo View Post
    Rpool

    If you truly want a "sleep" or "wait", as an alternative to CDrive's
    suggestion, check out RhinoBull's snippet in this thread (post #2):

    http://www.vbforums.com/showthread.php?t=652682

    Spoo
    That is a very common method but it's a CPU hog. The WaitMessage API is the opposite.
    <--- 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??

  8. #8
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: When need "DoEvents" and/or "Sleep"

    CDrive

    Good to know. Thanks for info.

    Spoo

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