Results 1 to 4 of 4

Thread: Responding other events while executing a long routine

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    136

    Smile Responding other events while executing a long routine

    Hai,
    I am writing a routine which will take much time,i have written this routine in a module and calling from command button's click event.But while executing that rotine if the user clinks another button i have to stop this routine. Pls help me to achieve this.
    Thank you.

  2. #2
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Responding other events while executing a long routine

    Try adding DoEvent within that sub, or in a loop especially.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



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

    Re: Responding other events while executing a long routine

    In order for DoEvents to be meaningful at all it must be put in a loop structure because it's only called at that instant. DoEvents is only relevant to your program not your OS. DoEvents can slow things down but in many instances it's a must have.
    <--- 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??

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Responding other events while executing a long routine

    When using DoEvents make sure that you disable the loop in question from being called again whilst it is still running. Example...
    Code:
    Private Sub Command1_Click()
        Command1.Enabled = False
        'The big loop with Doevents
        Command1.Enabled = True
    End Sub

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