# vb2Py - Do ... Loop

Contents of this page:

- General
- Default Conversion
- List of Options

Different forms:

- Do ... Loop
- Do While ... Loop
- Do ... Loop While
- Do Until ... Loop
- Do ... Loop Until

# General

All variations of VB's `Do ... Loop` construct are converted to an equivalent Python `while` block. Preconditions are converted to the equivalent condition in the `while` statement itself, whereas post-conditions are implemented using an `if ...: break` . `Exit's` from the loop are also implemented using `break` . `Until` conditions (pre or post) are implemented by negating the condition itself but do not affect the structure.

# Default Conversion

## Do ... Loop

VB | Python
--- | ---
    Do
        Val = Val + 1
        If SomeCondition Then Exit Do
    Loop
        while 1:
            Val = Val + 1
            if SomeCondition:
                break

## Do While ... Loop

VB | Python
--- | ---
    Do While Condition
        Val = Val + 1
        If SomeCondition Then Exit Do
    Loop
        while Condition:
            Val = Val + 1
            if SomeCondition:
                break

## Do ... Loop While

VB | Python
--- | ---
    Do
        Val = Val + 1
        If SomeCondition Then Exit Do
    Loop While Condition
        while 1:
            Val = Val + 1
            if SomeCondition:
                break
            if not (Condition):
                break

## Do Until ... Loop

VB | Python
--- | ---
    Do Until Condition
        Val = Val + 1
        If SomeCondition Then Exit Do
    Loop
        while not (Condition):
            Val = Val + 1
            if SomeCondition:
                break

## Do ... Loop Until

VB | Python
--- | ---
    Do
        Val = Val + 1
        If SomeCondition Then Exit Do
    Loop Until Condition
        while 1:
            Val = Val + 1
            if SomeCondition:
                break
            if Condition:
                break

# List of Options

There are no options for the `Do ... Loop` construct.