VB.Net/Language Basics/Do While

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

Do Loop While

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

End Class


Do While Loop

Imports System
public class MainClass
    Shared Sub Main()
       Dim counterVariable As Integer = 0
       Do While counterVariable < 10
          Console.WriteLine("counterVariable: {0}", counterVariable)
          counterVariable = counterVariable + 1
       Loop 
    End Sub
End Class


If inside Do While loop

Imports System
public class MainClass
    Shared Sub Main()
       Dim counterVariable As Integer = 0
       Do
          Console.WriteLine("counterVariable: {0}", counterVariable)
          counterVariable = counterVariable + 1
          If counterVariable > 9 Then
             Exit Do
          End If
       Loop
    End Sub
End Class