|
-
Oct 10th, 2000, 05:31 AM
#1
Thread Starter
Member
I'd like to add a Cancel button to a form whereby I could interrupt a certain program task, typically a time-consuming one, for example:
for i1=1 to largeNumber1
for i2=1 to LargeNumber2
WorkOnSomethingCumbersome
next
next
How can I have the cancel button take me out of the loops and to the exit point of the procedure?
-
Oct 10th, 2000, 06:48 AM
#2
Couldn't you have something like this? There is probably a more efficient way but:
Code:
Dim Canceled as Boolean
Private Sub cmdCancel_Click()
Canceled = True
End Sub
THEN
Code:
for i1=1 to largeNumber1
for i2=1 to LargeNumber2
If Canceled = True Then Exit For ' or exit sub/function
WorkOnSomethingCumbersome
next i2
-
Oct 10th, 2000, 06:59 AM
#3
Member
Dont forget the DoEvents
That code looks good, but don't forget to put DoEvents in your code to give the user the opportunity to click on the cancel button. Also disable all other things he may not use during the proces. But you probably thought about this anyway.
A mind is like a parachute, it has to open to let it work
www.2beesoft.com for Icon Manager with over 20.000 free icons
VB6 Ent. SP4, ASP, W2000/W98
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|