Results 1 to 3 of 3

Thread: Exit Sub

  1. #1
    Guest

    Question

    I have an app where a lengthy procedure is being run in a module while the results are being written to a form with a cancel button. When the user clicks cancel, I want to stop executing the sub in the module.

    Is there any way to unconditionally break the execution of a procedure from another form?

    Essentially, I want to inject an "exit sub" unconditionally at whatever point the sub is at.

    Any help would be appreciated.

    John

  2. #2
    Guest
    take a look on 'DoEvents' in the VB documentation.

    best regards

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    the only way to do this perfectly would be to multi thread but that's far more hassle than it's worth, have a look at the doevents, and have a booloean variable called boolKeepRunning, get your cancel button to set boolKeepRunning to False, and after your doevents code put If Not boolKeepRunning Then Exit Sub

    hope this helps.

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