Do...Loop Statement

Kordab lause Do ja Loop vahelisi lauseid, kui tingimuse vÀÀrtus on vÔi kuni selleks saab TÔene.

SĂŒntaks

Do [{While | Until} condition = True]

lause sisu

[Exit Do]

lause sisu

Loop

vÔi

Do

lause sisu

[Exit Do]

lause sisu

Loop [{While | Until} condition = True]

Parameetrid/Elemendid

Condition: A comparison, numeric or string expression, that evaluates either True or False.

Statement block: laused, mida soovid korrata, kui vÔi kuni tingimuse vÀÀrtus on TÔene.

Lause Do...Loop kĂ€ivitab tsĂŒkli seni vĂ”i kuni mÀÀratud tingimuse vÀÀrtus on TĂ”ene. TsĂŒklist vĂ€ljumise tingimus peab olema sisestatud lause Do vĂ”i Loop jĂ€rele. JĂ€rgmised nĂ€ited on sobivad kombinatsioonid:

SĂŒntaks

Do While condition = True

...lause sisu

Loop

Lausete Do While ja Loop vahelist lause sisu korratakse seni, kuni tingimus on tÔene.

Do Until condition = True

...lause sisu

Loop

Lausete Do Until ja Loop vahelist lause sisu korratakse seni, kuni tingimus on vÀÀr.

Do

...lause sisu

Loop While condition = True

Lausete Do ja Loop vahelist lause sisu korratakse seni, kuni tingimus on tÔene.

Do

...lause sisu

Loop Until condition = True

Lausete Do ja Loop vahelist lause sisu korratakse, kuni tingimus on tÔene.

TsĂŒklist tingimusteta vĂ€ljumiseks kasuta lauset Exit Do. Selle lause saad lisada suvalisse kohta lauses Do...Loop. VĂ€ljumistingimuse saad mÀÀrata ja struktuuri If...Then abil jĂ€rgmiselt:

Do...

laused

If condition = True Then Exit Do

laused

Loop...

NĂ€ide


Sub ExampleDoLoop
Dim sFile As String
Dim sPath As String
    sPath = "c:\"
    sFile = Dir$( sPath ,22)
    If sFile <> "" Then
        Do
            MsgBox sFile
            sFile = Dir$
        Loop Until sFile = ""
    End If
End Sub

Palun toeta meid!