Do while Loop
Submitted by joken on Monday, October 28, 2013 - 18:25.
A do while loop is a control flow statement that allows code to be executed once based on a given boolean condition. In visual basic, you can use do while loop structure when you want to repeat a set of statements of an indefinite number of times, until a condition is satisfied.
Syntax:
Code Explanation:
1. Declare num variable as Integer
2. Then we use the Do While Loop to check if num is less than twenty
3. If less than twenty, it is true
4. Since it is true, we increment num by 1
5. Until it reaches 20 then, the statement will become false
6. Then we display the current value of num.
Do While condition [ statements ] [ Continue Do ] [ statements ] [ Exit Do ] [ statements ] LoopThe Do while loop evaluate something that is true Example:
- Dim num As Integer
- Do While num < 20
- num = num + 1
- Loop
Add new comment
- 168 views