'Do...Loop Statements ' execute a program block repeately while a Boolean Condiltion is true or else it exits the loop. ' The general form is ' DO[{WHILE|UNTIL} condition] ' [statements] ' [Exit Do] ' [statements] ' LOOP[{WHILE|UNTIL} condtion] ' There are four ways of writing this loop. Two ways use WHILE, the other two ways use UNTIL. ' WHILE counts from bottom to top and UNTIL counts from top to bottom.
Sub Main()
Dim x As Short x=1 Do While x<5 Debug "*" x+=1 'display 4 asterisks Loop Debug CR 'moves to next line x=1 Do Debug "*" x+=1 'display 4 asterisks Loop While x<5 Debug CR x = 5 Do Until x=0 Debug "*" x-=1 'display 5 asterisks Loop Debug CR x = 5 Do Debug "*" x-=1 'display 5 asterisks Loop Until x=0 End Sub
|
|