Module
Contents
Index 🔎︎

# Do...Loop Statement

Repeats the statements between the Do and the Loop statement while the condition is True or until the condition becomes True.

## Sintaksa

Do [{While | Until} condition = True]

Shigjetat e bllokut

Teposhtë

Shigjetat e bllokut

Loop de Loop

ose

Teposhtë

Shigjetat e bllokut

Teposhtë

Shigjetat e bllokut

Loop [{While | Until} condition = True]

## Elementet e adresës

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:

## Sintaksa

Do While condition = True

Shigjetat e bllokut

Loop de Loop

The statement block between the Do While and the Loop statements is repeated so long as the condition is true.

Do Until condition = True

Shigjetat e bllokut

Loop de Loop

The statement block between the Do Until and the Loop statements is repeated if the condition so long as the condition is false.

Teposhtë

Shigjetat e bllokut

Loop While condition = True

The statement block between the Do and the Loop statements repeats so long as the condition is true.

Teposhtë

Shigjetat e bllokut

Loop Until condition = True

The statement block between the Do and the Loop statements repeats until the condition is true.

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:

Teposhtë

DDE Deklaratë

If condition = True Then Exit Do

DDE Deklaratë

Loop de Loop

## Shembull

    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