VB While loop


It executes a series of statements as long as a given condition is True.

Syntax

While condition
    [ statements ]
    [ Continue While ]
    [ statements ]
    [ Exit While ]
    [ statements ]
End While

Example

Module loops
   Sub Main()
      Dim a As Integer = 10
      ' while loop execution 
      While a < 20
          Console.WriteLine("value of a: {0}", a)
          a = a + 1
      End While
      Console.ReadLine()
   End Sub
End Module

Share this article on