View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default short circuit for next; continue?

There's not a direct equivalent to 'continue' in VB but two ways to achieve
same with your example

for x = 2 to y

answer = sub_testing()
if answer < 1 then

do more stuff
do more stuff

end if

next


for x = 2 to y

answer = sub_testing()
if answer = 1
goto continue
end if

do more stuff
do more stuff

continue:
next

("continue" here is just a label named whatever you want)

I should add purists don't like use of Goto and will give all sorts of
(good) reasons not to use it. That said if used sparingly it can be useful.

Regards,
Peter T


"cate" wrote in message
...
Is there a way to do this in vba? (I can do this with structure but I
want to know if there is a perl/C# analog to (continue")

for x = 2 to y

answer = sub_testing()
if answer = 1
continue ' skip the reset of loop code and go back and get the
next value. No point in going on
end if

do more stuff
do more stuff

next

thank you.