NevSoFly
asked on
How would I exit an outer for loop from within an inner for loop?
I have the following:
For a = 0 to 10
For b = 0 to 10
If (some condition) then
'do something
else
exit outer loop (a) 'this is what I can't figure out how to do.
End if
Next b
Next a
How do I exit the outer For loop (a) from within For loop (b)?
For a = 0 to 10
For b = 0 to 10
If (some condition) then
'do something
else
exit outer loop (a) 'this is what I can't figure out how to do.
End if
Next b
Next a
How do I exit the outer For loop (a) from within For loop (b)?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would say that is only partially correct. There are times when a for loop does make sense eg. iterating an array, and one may want to exit the for loop before the end of the array is reached.
What is certain is that a for loop could be written as a while loop BUT that might be the same code in effect - just requiring more lines of code to be written.