Responding other events while executing a long routine
Hai,
I am writing a routine which will take much time,i have written this routine in a module and calling from command button's click event.But while executing that rotine if the user clinks another button i have to stop this routine. Pls help me to achieve this.
Thank you.
:wave:
Re: Responding other events while executing a long routine
Try adding DoEvent within that sub, or in a loop especially.
Re: Responding other events while executing a long routine
In order for DoEvents to be meaningful at all it must be put in a loop structure because it's only called at that instant. DoEvents is only relevant to your program not your OS. DoEvents can slow things down but in many instances it's a must have.
Re: Responding other events while executing a long routine
When using DoEvents make sure that you disable the loop in question from being called again whilst it is still running. Example...
Code:
Private Sub Command1_Click()
Command1.Enabled = False
'The big loop with Doevents
Command1.Enabled = True
End Sub