VBScript While...Wend 循环

While..Wend 循环中,如果条件为 True,则执行所有语句,直到遇到 Wend 关键字。

如果条件为 false,则退出循环,并且控制跳转到 Wend 关键字之后的下一个语句。

语法

VBScript 中 While..Wend 循环的语法是 −

While condition(s)
   [statements 1]
   [statements 2]
   ...
   [statements n]
Wend

流程图

While 循环架构

示例

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim Counter :  Counter = 10   
         While Counter < 15    ' Test value of Counter.
            Counter = Counter + 1   ' Increment Counter.
            document.write("The Current Value of the Counter is : " & Counter)
            document.write("<br></br>")
         Wend ' While loop exits if Counter Value becomes 15.
         
      </script>
   </body>
</html>

当执行上述代码时,它会在控制台中打印以下输出。

The Current Value of the Counter is : 11 

The Current Value of the Counter is : 12 

The Current Value of the Counter is : 13 

The Current Value of the Counter is : 14 

The Current Value of the Counter is : 15

vbscript_loops.html