Exit from While Loop : While « Language Basics « VB.Net






Exit from While Loop

Exit from While Loop
Imports System

Public Class MainClass

    Shared Sub Main(ByVal args As String())
      Dim counter As Integer


      While counter <= 10
         ' skip remaining code in loop only if counter = 7
         If counter = 7 Then
            Exit While
         End If

         counter += 1
      End While

      Console.WriteLine( "counter = " & counter & _
         " after exiting While structure")

    End Sub
End Class

           
       








Related examples in the same category