-
I have a program that processes for a long time. I would like to be able to push a button on the form that can stop the processing if I need it to. Currently the button's code is not executed until after the processing is done. How can I make it so that the button's code is executed while the other processing is going on. Any help is greatly appreciated.
-
Here's an example :)
Code:
Private StopMe As Boolean
Sub Form_Load()
StopMe = False
End Sub
Sub LongLoop()
Dim x&
x = 0
Do While x < 10000 and StopMe = False
x = x + 1
DoEvents 'Important!
Loop
End Sub
Sub Command1_Click()
StopMe = True
End Sub
Sub Form_Unload(Cancel As Integer)
StopMe = True
End Sub