Do...Loop Statement

Ponavljaj naredbu između Do i Loop naredbi dok je uvjetistinit ili dok uvjet ne postane istinit

Syntax

Do [{While | Until} condition = True]

blok izraza

[Exit Do]

blok izraza

Petlja

or

Čini

blok izraza

[Exit Do]

blok izraza

Petlja [{While | Until} condition = True]

Parametri/elementi

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

Statement block: Statements that you want to repeat while or until the condition is True.

The Do...Loop statement executes a loop as long as, or until, a certain condition is True. The condition for exiting the loop must be entered following either the Do or the Loop statement. The following examples are valid combinations:

Syntax

Radi dok uvjet = True (istinit)

...blok izjava

Petlja

Blok naredbi između Do While i Loop naredbi ponavlja se dok je uvjet istinit

Radi dok uvijet =True (istina)

...blok izjava

Petlja

Blok naredbi između Do Until i Loop naredbi ponavlja se dok je uvjet netočan.

Čini

...blok izjava

Petlja While uvjet = True (istinit)

Blok naredbi između Do i Loop naredbi ponavlja se dok je uvjet istinit

Čini

...blok izjava

Petlja Until uvjet = True (istina)

Blok naredbi između Do i Loop naredbi ponavlja se dok uvjet ne bude istinit

Use the Exit Do statement to unconditionally end the loop. You can add this statement anywhere in a Do...Loop statement. You can also define an exit condition using the If...Then structure as follows:

Napravi...

naredbe

If condition = True Then Exit Do

naredbe

Petlja...

Primjer


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

Please support us!