[RESOLVED] How can i exit out of a For Next loop? Is it possible?
Is there a way to exit out of a For Next loop? Like
Code:
For i = 0 to 5
If i = 3 then
'exit loop
End If
Next i
Re: How can i exit out of a For Next loop? Is it possible?
Code:
For i = 0 to 5
If i = 3 then
Exit For
End If
Next i
Re: How can i exit out of a For Next loop? Is it possible?
You also have the Exit Do for exiting Do Loops if you ever need it.
Re: How can i exit out of a For Next loop? Is it possible?
Or Exit While for exiting While Loops.
Exit Sub / Exit Function too
Re: How can i exit out of a For Next loop? Is it possible?
Actually, there's no Exit While for While Wend loops in VB6. (but I think there is in .Net, not sure, I don't use it much)
EDIT: Valid Exits are Do, For, Sub, Function and Property.
Re: How can i exit out of a For Next loop? Is it possible?
Okay. Thanks everyone for your awnseres!
Re: [RESOLVED] How can i exit out of a For Next loop? Is it possible?
For nested loops, the simplest way is using GoTo, in case you ever run into this problem. You could probably use a boolean check to exit each loop consecutively... but this is probably even less ideal than GoTo.
Re: [RESOLVED] How can i exit out of a For Next loop? Is it possible?
So, would this maybe be why this problem of mine happens: http://www.vbforums.com/showthread.p...26#post3806126 ?