Stop a Procedure from another procedure
Ayo wrote:
How do you stop a procedure by click another button. I want to be able to
click button2 to stop the procedure being run by button1.
Private Sub button1_Click()
runingProcedure
End Sub
Private Sub button2_Click()
stop runingProcedure
End Sub
One idea:
Add a module-level or global variable that will be set in button2_Click.
Add code to button1_Click to check the state of this variable in one or
more places as needed.
It's also a good idea to add DoEvents tactically in the button1_Click
code to make sure the click event on button2 is captured appropriately.
Also... make sure you do any necessary cleanup in button1_Click so it
exits gracefully.
|