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