Exit a Loop : Exit « Language Basics « VB.Net






Exit a Loop

Exit a Loop
Imports System

Public Class MainClass

    Shared Sub Main(ByVal args As String())
       Dim counterVariable As Integer = 0
       Do
          Console.WriteLine("counterVariable: {0}", counterVariable)
          counterVariable = counterVariable + 1

          ' test whether we've counted to 9, if so, exit the loop
          If counterVariable > 9 Then
             Exit Do
          End If
       Loop
    End Sub


End Class

           
       








Related examples in the same category

1.Exit an ApplicationExit an Application
2.Exit a Do While LoopExit a Do While Loop