HandsOn Using the DoUntil Loop with a Condition at the Bottom of the Loop

1. In the Visual Basic Editor window, insert a new module and type the following procedure:

Sub PrintNumbers() Dim num As Integer num = 0 Do num = num + 1 Debug.Print num Loop Until num = 27 End Sub

The variable num is initialized at the beginning of the procedure to zero (0). When Visual Basic enters the loop, the content of the variable num is increased by one, and the value is written to the Immediate window with the Debug.Print statement. Next, the condition tells Visual Basic that it

Part I

should execute the statements inside the loop until the variable num equals 27.

0 0

Post a comment