// While...Wend Example
/* While...Wend repeats a group of statements */
var Counter = 1;
while (Counter < 5) {
NSB.Print("Counter = " + Counter);
Counter++;
}
No edit summary |
No edit summary |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
While ''condition'' <br /> | While ''condition'' <br /> | ||
:::[''statements''] <br /> | :::[''statements''] <br /> | ||
Wend | |||
== Description == | == Description == | ||
While... | 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 == | == Example == | ||
< | <tabber> | ||
Rem While... | JavaScript= | ||
'While... | <syntaxhighlight lang="JavaScript"> | ||
// While...Wend Example | |||
/* While...Wend repeats a group of statements */ | |||
var Counter = 1; | |||
while (Counter < 5) { | |||
NSB.Print("Counter = " + Counter); | |||
Counter++; | |||
} | |||
</syntaxhighlight> | |||
|-| | |||
BASIC= | |||
<syntaxhighlight lang="vb.net"> | |||
Rem While...Wend Example | |||
'While...Wend repeats a group of statements | |||
Dim Counter | Dim Counter | ||
Counter = 1 | Counter = 1 | ||
Line 17: | Line 32: | ||
Print "Counter = " & Counter | Print "Counter = " & Counter | ||
Counter = Counter + 1 | Counter = Counter + 1 | ||
Wend</syntaxhighlight> | |||
</ | </tabber> | ||
== Output == | == Output == | ||
Line 31: | Line 46: | ||
== Related Items == | == Related Items == | ||
[[do...loop| | [[do...loop|Do...Loop]], [[for...next|For...Next]], [[for each...next|For Each...Next]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
[[Category:Statements - Flow of control]] |
While condition
Wend
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.
// While...Wend Example
/* While...Wend repeats a group of statements */
var Counter = 1;
while (Counter < 5) {
NSB.Print("Counter = " + Counter);
Counter++;
}
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
Counter = 1 Counter = 2 Counter = 3 Counter = 4