-
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
-
take a look on 'DoEvents' in the VB documentation.
best regards
-
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.