VBScript While ... Wend Loop

Em um While..Wend loop, se a condição for True, todas as instruções são executadas até Wend palavra-chave for encontrada.

Se a condição for falsa, o loop é encerrado e o controle pula para a próxima instrução após Wend palavra-chave.

Sintaxe

A sintaxe de um While..Wend loop em VBScript é -

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

Diagrama de fluxo

Exemplo

<!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>

Quando o código acima é executado, ele imprime a seguinte saída no console.

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