Reputation: 2067
I just moved over to the Visual Basic team here at work.
What is the equivalent keyword to break
in Visual Basic, that is, to exit a loop early but not the method?
Upvotes: 115
Views: 149042
Reputation: 30518
In both Visual Basic 6.0 and VB.NET you would use:
Exit For
to break from For loopWend
to break from While loopExit Do
to break from Do loopdepending on the loop type. See Exit Statements for more details.
Upvotes: 201
Reputation: 8605
Exit
[construct], and intelisense will tell you which one(s) are valid in a particular place.
Upvotes: 6
Reputation: 2610
In case you're inside a Sub of Function and you want to exit it, you can use :
Exit Sub
or
Exit Function
Upvotes: 7