Ratakan

Informations :

Do Loop While In VB.NET


Do Loop While In VB.NET

How to use Do Loop While?

Explanation

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
Syntax:

Do
[Statements]
Loop While [Condition]

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

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

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.

No comments