Skip to main content This browser is no longer supported. Show
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Do...Loop Statement (Visual Basic)
In this articleRepeats a
block of statements while a Syntax
Parts
RemarksUse a You can use either You can test The condition usually results from a comparison of two values, but it can be any expression that evaluates to a
Boolean Data Type value ( You can nest Note The Exit DoThe Exit Do statement can provide an alternative way to exit a
You can include any number of When used within nested Example 1In the following example, the statements in the loop continue to run until the
Example 2The following example uses a
Example 3In the following example,
Example 4The following example reads all lines in a text file. The OpenText method opens the file and returns a StreamReader that reads the characters. In the
See also
FeedbackSubmit and view feedback for Which type of loop causes a statement or set of statements to repeat as long as a condition is true?Which pair of loops causes a statement or set of statements to repeat as long as a condition is true? The While loop is known as a pretest loop, which means it tests its condition before performing an iteration.
What type of loop uses a Boolean expression?The while-loop uses a boolean test expression to control the run of the body lines.
What type of loop executes a procedure as long as the test condition is true?A for-loop always makes sure the condition is true before running the program.
Which structure causes a statement or set of statements to execute repeatedly?A repetition structure causes a statement or set of statements to execute repeatedly. Repetition structures are used to perform the same task over and over. A condition-controlled loop uses a Boolean (true/false) condition to control the number of times that it repeats.
What repeats a statement or group of statements while a given condition is true?Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable.
|