Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

skip a loop

Status
Not open for further replies.

g2000

Programmer
Joined
Aug 31, 2005
Messages
39
Location
US
How to skip any loop?
For instance,

ans = 0
For i=Lbound(a) to UBound(a)
if a(i) = "1" Then
???
else
answer = answer + cint(a(i))
Next

Or simply speaking, what is the vbscript equivalent of java-continue? thanks
 
You just did it. There isn't any equivalent, so you have to do it with conditionals, like you just showed. Instead of ??? you can use a comment, or you can invert the logic and leave off the else part.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Exit For won't continue the loop, it will end it. That's not what the OP is looking for. They want a command that will skip the rest of the stuff inside the for loop and go back to the top of the loop. There is no syntactical reason to have such a command, you can easily do without it just as the OP demonstrated above. It's just for convenience. I'm surprised Java even has such a command, since it is otherwise such a strict language, and that kind of command violates a major precept of structured programming - one entry, one exit.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top