vb2Py - Do ... Loop

Contents of this page:

Different forms:

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

VBPython

Do
Val = Val + 1
If SomeCondition Then Exit Do
Loop




while 1:
Val = Val + 1
if SomeCondition:
break

Do While ... Loop

VBPython

Do While Condition
Val = Val + 1
If SomeCondition Then Exit Do
Loop




while Condition:
Val = Val + 1
if SomeCondition:
break

Do ... Loop While

VBPython

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

VBPython

Do Until Condition
Val = Val + 1
If SomeCondition Then Exit Do
Loop




while not (Condition):
Val = Val + 1
if SomeCondition:
break

Do ... Loop Until

VBPython

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.