Do While Loop In VB.NET

How to use Do While Loop?


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.

Do While [Condition]

In the above syntax the Statements are executed till the Condition remains true.

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)
End Sub

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.

Visual Basic Tutorial

Ask Questions

Ask Question