VB.Net/Language Basics/Do Until

Материал из VB Эксперт
Версия от 12:42, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Do Until Loop

Imports System
Public Class MainClass
    Shared Sub Main(ByVal args As String())
       Dim counterVariable As Integer = 0
       Do Until counterVariable = 10
          Console.WriteLine("counterVariable: {0}", counterVariable)
          counterVariable = counterVariable + 1
       Loop " Until counterVariable = 10
    End Sub

End Class


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