While . . . Wend – Just another Looping Structure in VBScript

by seetaram on September 7, 2011

This does not have any special features other than what is explained with Do While . . . Loop.  This looping structure also works the same way like Do While . . Loop.  While . . . Wend is an older looping syntax and Do . . Loop is preferred over this.  The drawback of this loop is that there is no command to stop the execution in between using something like Exit For or Exit Do.

Syntax:

While {Condition}

- – - – - – - –

Block of code

- – - – - – - –

Wend

Example:

i=1
j=1
While i<20

        While j<i
            s=s&"*"
            j=j+1
        Wend

        s=s&vbnewline
  i=i+1
  j=1

Wend

msgbox s

Above example uses two While .. Wend loops and gives the output as a triangle of stars.

Output will be as below:

*
**
***
****
*****
******
*******
********
*********
**********
***********
************
*************
**************

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email