Link to home
Start Free TrialLog in
Avatar of sstjacques
sstjacques

asked on

Cancel event

I'm looking for a way to kill all processing with a cancel button without exiting the program.  In fact, I'm using a timer to verify a condition and I want to exit the function running...
ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Like this;

Private bCancel As Boolean

Private Sub Command1_Click()
    Do
        'Do your processing
        If bCancel Then Exit Do
        DoEvents
    Loop 'Until ...
End Sub

Private Sub Command2_Click()
    'Stop the processing
    bCancel = True
End Sub