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 What can a definite loop also be referred to as?Types of condition-controlled iteration include while loops, do while loops, and repeat until loops. Count-controlled iteration (also known as definite iteration) is when a set of instructions is repeated a specific number of times. Types of count-controlled loop include for loops and for each loops.
When a loop is placed within another loop the loops are said to be?A nested loop is a loop within a loop, an inner loop within the body of an outer one. How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again.
What is the term for one execution of a loop?A single execution of the loop body is called an iteration. The loop in the example above makes three iterations.
Is a structure that allows repeated execution of a block of statements as long as a tested expression is true?A loop is a structure that allows repeated execution of a block of statements. Within a looping structure, a Boolean expression is evaluated. If it is true, a block of statements called the loop body executes and the Boolean expression is evaluated again.
|