Writing Loops
A loop is a series of statements that executes repetitively until some condition is true. Coding a loop requires a statement that marks the loop’s beginning, another statement that marks its end, and a condition that controls whether the loop keeps executing or stops.
Visual Basic .NET supports three basic constructs for writing and controlling loops: Do…Loop, For…Next, and While…End While. In each case, the keyword before the ellipsis defines the start of the loop and the keyword after the ellipsis defines its end.
Coding Loops with Do…Loop Statements
The code for a simple Do loop appears below. The Dim statement isn’t part of the loop; it’s only there for your information.
Dim intCount as Integer = 0 Do intCount = intCount + 1 Loop ...
Get Faster Smarter Beginning Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.