Do While Loop In VB.NET
How to use Do While Loop?
Explanation
Do While Loop Statement
Do While Loop Statement is used to execute a set of statements only if the condition is satisfied. But the loop
get executed once for a false condition once before exiting the loop. This is also know as
Entry Controlled loop.
Syntax:
Do While [Condition]
[Statements]
Loop
In the above syntax the
Statements are executed till the
Condition remains true.
Example:
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As Integer
a = 1
Do While a < 100
a = a * 2
MsgBox("Product is::" & a)
Loop
End Sub
Description:
In the above Do While Loop example the loop is continued after the value 64 to display 128 which is false according to the
given condition and then the loop exits.