While Wend Statement in VB.NET

What is a while wend statement in VB.NET?

Explanation

While Wend Statement

While Wend Statement is a looping statement where a condition is checked first, if it is true a set of statements are executed. The condition can also become false atleast once while this statement is used.
Syntax:

While condition
[statements]
Wend

In the above syntax the Statements are executed when the Condition is true. The condition may also become false while the statements are executed.
Example:

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim n As Integer
n = 1
While n <= 1
n = n + 1
MsgBox("First incremented value is:" & n)
End While
End Sub
Description:

In the above example, the value of n is 2 in the loop, which is false according to the condition but the loop is continued until the condition is checked. Thus the while wend statement can be used.

Visual Basic Tutorial


Ask Questions

Ask Question