While Loops (VBScript)

A while loop in VBScript takes on a form that is more commonly recognized as a do…while loop. The most basic syntax is:

Dim Counter
Dim Continue

Counter = 0

Do
    Counter = Counter + 1
    Continue = InputBox("Do you want to continue counting? (Enter 'y' for yes)")
Loop While Continue = "y"

MsgBox(Counter)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License