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.
Syntax:
Do While
statements…
Loop
Note that:
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.
Example:
Do While count<=5
count = count + 1
Loop
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.
Syntax:
Do
Loop While
No comments:
Post a Comment
You can ask your queries here and we will try to get back to you as soon as we will be done working with that..
Note: Only a member of this blog may post a comment.