Do Loop While In VB.NET

How to use Do Loop While?


Do Loop While Statement

Do Loop While Statement executes a set of statements and checks the condition, this is repeated until the condition is true. It is also known as an Exit Control loop

Loop While [Condition]

In the above syntax the Statements are executed first then the Condition is checked to find if it is true.

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnt As Integer
cnt = 10
MsgBox("Value of cnt is::" & cnt)
Loop While cnt <= 9
End Sub

In the above Do Loop While example, a message is displayed with a value 10 only after which the condition is checked, since it is not satisfied the loop exits.

Visual Basic Tutorial

Ask Questions

Ask Question