VB.Net/Language Basics/Exit

Материал из VB Эксперт
Перейти к: навигация, поиск

Exit a Do While Loop

<source lang="vbnet"> Imports System Public Class MainClass

   Shared Sub Main()
       "Declare variable
       Dim intCount As Integer = 0
       "Process the loop
       Do While intCount < 10
           "Add the item to the list
           System.Console.WriteLine(intCount)
           "Increment intCount by 1
           intCount += 1
           "Should you quit
           If intCount = 3 Then
               Exit Do
           End If
       Loop
   End Sub

End Class

      </source>


Exit a Loop

<source lang="vbnet"> 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

      </source>


Exit an Application

<source lang="vbnet"> Public Class MainClass

  Shared Sub Main()
     System.Environment.Exit(System.Environment.ExitCode)
  End Sub " ValidationError

End Class


      </source>