Jump to content

How to exit from for loop


likecoding

Recommended Posts

Hi, 

For i = 1 to 5
' do somthing

For j = 1 to 5
' do something
if a = b then 
  exit for
end if
Next

Next

'' continue here

I have two for loops. If a = b how can I exit out from both loops so it will continue from the line says "continue here" ?Currently, it exits out of inner loop only. 

 

Thanks.

Link to comment
Share on other sites

I don't know if that statement takes any other value to tell it how many levels to exit, but if not then can set a variable before you exit that you can check in the outer loop to see whether or not to exit.  That's a little confusing though and suggests that there's a more efficient way to design what you're trying to do.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...