VBScript while..Wend Loop

VBScript while..Wend Loop

  1. In VBScript, While..Wend is used for representing a while loop.
  2. If condition is true then all the statements until the Wend keyword will be executed.
  3. Wend represents end of while block in VBScript
  4. If condition become false then statement next to Wend Keyword will be executed.

While..Wend Syntax

Below statements are used to represent the While..Wend loop

While condition(s)
   [statements 1]
   [statements 2]
   [statements 3]
   [statements n]

Flow Diagram

While Loop Architecture

While..Wend Example

<!DOCTYPE html>
<script language="vbscript" type="text/vbscript">
  Dim i :  i = 0   
  While i < 5
    i = i + 1
    document.write("Value of the i is : " & i)

When the above code is executed, it prints the following output in the console.

Value of the i is : 1 
Value of the i is : 2 
Value of the i is : 3 
Value of the i is : 4 
Value of the i is : 5