Visual Basic - Loop with condition on the beginning: while end while, do while loop
Condition testing is done at the beginning of the loop. before each iteration the condition is tested, if it is was true. before the first iteration is a condition test, the use of this loop is excellent in situations where perhaps we don't need to execute the cycle.while end while
Description
while condition
statements
end while
Input
- condition - Logical value The condition can be any expression
- statements - statements
Examples
Visual Basic .NET
Loop with condition on the beginning the possible of use:i=0
while i<10
i=i+1
end while
x =0
while i<20
i= i+2
if i=16 then
continue while
end if
x=x+1
end while
Visual Basic .NET
Other pieces of example codes:while i>0 if i=10 then exit do else i=i-1 end if end while
if x >= 12 then while y >= 0 y=y-1 end while end if
while y <= 32 y=y+1 end while
do while loop
Description
do while condition
statements
loop
Input
- condition - Logical value The condition can be any expression
- statements - statements
Examples
Visual Basic .NET
Loop with condition on the beginning the possible of use:i=0
while i<10
i=i+1
end while
x =0
while i<20
i= i+2
if i=16 then
continue while
end if
x=x+1
end while
Loop with condition on the beginning in another programming language:
Differences to: