While...Wend: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
While ''condition'' <br /> | |||
:::[''statements''] <br /> | :::[''statements''] <br /> | ||
WEnd | |||
== Description == | |||
While...WEnd repeats a group of statements while a given condition is TRUE. The required component, ''condition'', is any valid expression that evaluates to TRUE or FALSE. The optional component, ''statements'', are executed during each iteration of the loop. While...WEnd statements can be nested, and any WEnd statements in a nested loop transfer execution to one level above the loop where the WEnd occurs. | |||
== Example == | |||
<pre> | <pre> | ||
Rem While...WEnd Example | |||
' | 'While...WEnd repeats a group of statements | ||
Dim Counter | |||
Counter = 1 | Counter = 1 | ||
While Counter < 5 | |||
Print "Counter = " & Counter | |||
Counter = Counter + 1 | Counter = Counter + 1 | ||
WEnd | |||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
Line 29: | Line 29: | ||
</pre> | </pre> | ||
== Related Items == | |||
[[do...loop|DO...LOOP]], [[for...next|FOR...NEXT]], [[for each...next|FOR EACH...NEXT]] | [[do...loop|DO...LOOP]], [[for...next|FOR...NEXT]], [[for each...next|FOR EACH...NEXT]] | ||
[[Category:Language Reference]] |
Revision as of 04:23, 17 August 2012
While condition
- [statements]
- [statements]
WEnd
Description
While...WEnd repeats a group of statements while a given condition is TRUE. The required component, condition, is any valid expression that evaluates to TRUE or FALSE. The optional component, statements, are executed during each iteration of the loop. While...WEnd statements can be nested, and any WEnd statements in a nested loop transfer execution to one level above the loop where the WEnd occurs.
Example
Rem While...WEnd Example 'While...WEnd repeats a group of statements Dim Counter Counter = 1 While Counter < 5 Print "Counter = " & Counter Counter = Counter + 1 WEnd
Output
Counter = 1 Counter = 2 Counter = 3 Counter = 4