If you are controlling the animation with a loop here is a method i have used to break out of long running loops.
Define a boolean variable (in the declaration section of the form, so it will be visible to all procedures) to signal the animation loop to end.
Code:
Public BreakNow As Boolean
In the cancel button's event procedure, set this variable to true.
Code:
Private Sub cmdCancel_Click()
BreakNow = True
End Sub
In the animation loop, insert a DoEvents statement, otherwise the cmdCancel_Click event will not fire because the animation loop is the only code being executed.
Code:
Private Sub cmdAnimate_Click()
BreakNow = False
While NotDone 'it doesn't matter what kind of loop
DoEvents
If BreakNow = True Then
GoTo EndAnimation
End If
'the rest of your loop here
Wend
EndAnimation:
'clean up after the animation here
End Sub
Ruairi
Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.