VB.Net Tutorial/Statements/Do Until — различия между версиями

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

Текущая версия на 12:53, 26 мая 2010

Do Until Loop

Option Strict On
 Imports System
 Module Module1
    Sub Main( )
       Dim counterVariable As Integer = 0
       Do Until counterVariable = 10
          Console.WriteLine("counterVariable: {0}", counterVariable)
          counterVariable = counterVariable + 1
       Loop 
    End Sub
 End Module
counterVariable: 0
counterVariable: 1
counterVariable: 2
counterVariable: 3
counterVariable: 4
counterVariable: 5
counterVariable: 6
counterVariable: 7
counterVariable: 8
counterVariable: 9

Do Until/Loop (2)

Module Tester
    Sub Main()
        Dim product As Integer = 2
        Do Until product > 1000
            Console.Write("{0}  ", product)
            product = product * 2
        Loop
        Console.WriteLine("Smallest power of 2 " & _
           "greater than 1000 is {0}", product)
    End Sub 
End Module
2  4  8  16  32  64  128  256  512  Smallest power of 2 greater than 1000 is 1024