Proceeding to the "Next" value in the middle of a loop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm processing a standard loop

For i = 1 to X
Next i

In the middle of the loop I want to check a condition, and if the condition
is true, then I want to go to the next value of i, and start processing the
loop again from the beginning. My code looks something like

For i= 1 to X
 
For i = 1 to x
'do some stuff
If a <> b Then
'do some more stuff
End If
Next i

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Logically, your code is no different than what follows, except the following
will compile:

For i = 1 to X
If A <> B Then
'Do something here
End if
Next
 
Back
Top