Exit from Do Until : Do Until « Language Basics « VB.Net






Exit from Do Until

Exit from Do Until
Imports System

Public Class MainClass

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


      Do Until counter > 10

         ' skip remaining code in loop only if counter = 5
         If counter = 5 Then
            Exit Do
         End If

         counter += 1
      Loop

      Console.WriteLine("counter = " & counter & _
         " after exiting Do Until/Loop structure" & vbCrLf)

    End Sub
End Class

           
       








Related examples in the same category

1.Do Until LoopDo Until Loop