Do…loop is used to execute a block of statements for indefinite number of times. There are several variations of Do…Loop statement.
Each variation evaluates a numeric condition to determine whether to continue execution or not.
Do While <condition>
1.When Visual Basic executes Do While loop, it first tests condition.
2.If condition is False (zero), it skips past all the statements.
3.If it’s True (nonzero), Visual Basic executes the statements and then goes back to the Do While statement and tests the condition again.
Do While count<=5
count = count + 1
Here loop increments the value of count until it becomes equal or less than 5.
Another variation of Do…Loop statement executes the statement first and then tests condition after each execution. This variation guarantees at least one execution of statements.
Loop While <condition>