For Loops

mafrosis

Well-known member
Joined
Jun 5, 2006
Messages
88
Location
UK
Programming Experience
5-10
Ok maybe a stupid question, but in VB can you force a For loop onto the next iteration? Like continue in Java/C. We've got Exit For which is the same as break, but im looking to optimise a loop with a continue type statement.

Cheers guys
 
Sorry guys, should've spent more time googling first..

Turns out it was never there before - but in the advent of VB.NET 2005 it has finally arrived in the form of:

Continue [For/Do/While]
 
You should avoid using Continue if possible. It's a form of GoTo statement and leads to spagetti-ish code. It's better to use If blocks unless they cause readability issues by adding to much indenting. The better option depends on the situation but, all else being equal, Continue would be my second choice.
 
Back
Top