Hi,
Is there anyway to stopp a function in before hand?
My problem is that I have a for-loop as shown below:
Private Function Count()
For i = 30 To 0 Step -1
code...
Next
End Function
Lets say that I want to stopp the function or the for-loop before it has
reached 0, is there any way that I could do so?
I tryied by seeting i to 0, but it was not working.
Or even better, how do you stopp/kill a function you have started?
Please help.
thanx
//Kashif
*******
The brain is a wonderful organ; it starts working the moment you get up in
the morning and does not stop until you get to the office
*******
Jason Keats - 20 Dec 2007 00:23 GMT
| Hi,
|
[quoted text clipped - 20 lines]
|
| //Kashif
Private mbCancel As Boolean
Private Function Count()
For i = 30 To 0 Step -1
code...
DoEvents
If mbCancel Then Exit For
Next i
End Function
Private Sub cmdCancel_Click()
mbCancel = True
End Sub
In general, you should avoid using DoEvents. You must prevent other events
from being triggered while your loop is processing.
Also look at "Exit Do" for Do loops.
Hope this helps.