471,071 Members | 911 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

force next iteration in for...next

Is there any way in VB to force the next iteration in a For ... next loop
other than
using a GoTo?

I notice that in C++ you can use 'continue' and in other languages there are
syntax for this. Am I missing something?

For an example, if a = false I don't want the if b = true to execute.

for i = 1 to 10

if a = true
do stuff
else
'go to next iteration
end if

if b = true
do some more stuff
end if
next i

TIA,
Marc Miller

May 15 '06 #1
2 3414
"Marc Miller" <mm****@hotmail.com> schrieb:
Is there any way in VB to force the next iteration in a For ... next loop
other than
using a GoTo?


In VB.NET 2002/2003 you may want to use 'GoTo' together with a named label.
In VB.NET you can simply use 'Continue' or 'Continue For', depending on the
situation.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 15 '06 #2
> Is there any way in VB to force the next iteration in a For ... next
loop
other than
using a GoTo?
I notice that in C++ you can use 'continue' and in other languages
there are syntax for this. Am I missing something?

For an example, if a = false I don't want the if b = true to execute.

for i = 1 to 10

if a = true
do stuff
else
'go to next iteration
end if
if b = true
do some more stuff
end if
next i
TIA,
Marc Miller


VB 2005 introduced the Continue statement in VB. See http://msdn2.microsoft.com/en-us/library/801hyx6f.aspx.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
May 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

35 posts views Thread by Raymond Hettinger | last post: by
2 posts views Thread by Abdullah Khaidar | last post: by
10 posts views Thread by Brian Burgess | last post: by
1 post views Thread by DottingTheNet | last post: by
23 posts views Thread by Mitchell Vincent | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.