SoFunction
Updated on 2025-04-08

VBS tutorial: statement - While...Wend statement

While...Wend statement

When the specified condition isTrueWhen executing a series of statements.

While condition
&nbsp
;  Version [statements]
Wend

parameter

condition

numerical or string expression, the result of the calculation isTrueorFalse. ifconditionis Null, thenconditionBeing treated asFalse

statements

In the conditionTrueone or more statements executed when.

illustrate

ifconditionforTrue,butstatementsAll inWendAll statements before the statement will be executed, and then the control will be returned toWhilestatement, and recheckcondition. ifconditionStill forTrue, the above process is repeated. If notTrue, thenWendThe statement after the statement continues to execute the program.

While...WendLoops can be multi-layer nested structures. EachWendWith the nearestWhilestatement corresponds.

Notice Do...LoopStatements provide a more structured and more adaptable way to execute loops.

The following example shows how to use itWhile...WendStatement:

Dim CounterCounter = 0                'Initialize variables。While Counter < 20         ' Test counter value。   Counter = Counter + 1   ' Increase the counter。   Alert CounterWend                       ' The counter is greater than 19 terminates the loop。

Require

Version 1