Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems


VBScript While. . . Wend Statement

Executes a series of statements as long as a given condition is True.

Syntax: VBScript While. . . Wend Statement

While condition



Arguments: VBScript While. . . Wend Statement


A numeric or string expression that evaluates to True or False. If condition is Null, condition is treated as False.


One or more statements executed while condition is True.

Remarks: VBScript While. . . Wend Statement

If condition is True, all statements in statements are executed until the Wend statement is encountered. Control then returns to the While statement and condition is again checked. If condition is still True, the process is repeated. If it is not True, execution resumes with the statement following the Wend statement.

While...Wend loops can be nested to any level. Each Wend matches the most recent While.

The following example illustrates use of the While...Wend statement:

Dim Counter

Counter = 0   ' Initialize variable.

While Counter < 20   ' Test value of Counter.

   Counter = Counter + 1   ' Increment Counter.

   Alert Counter

Wend   ' End While loop when Counter > 19.


The Do...Loop statement provides a more structured and flexible way to perform looping.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.