VBA - Pendant les boucles Wend

Dans un While…Wend boucle, si la condition est Vrai, toutes les instructions sont exécutées jusqu'à ce que Wend le mot clé est rencontré.

Si la condition est fausse, la boucle est quittée et le contrôle passe à l'instruction suivante après le Wend mot-clé.

Syntaxe

Voici la syntaxe d'un While..Wend boucle en VBA.

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

Représentation schématique

Exemple

Private Sub Constant_demo_Click()
   Dim Counter :  Counter = 10   
   
   While Counter < 15     ' Test value of Counter.
      Counter = Counter + 1   ' Increment Counter.
      msgbox "The Current Value of the Counter is : " & Counter
   Wend   ' While loop exits if Counter Value becomes 15.
End Sub

Lorsque le code ci-dessus est exécuté, il imprime ce qui suit dans une boîte de message.

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