Boucle textbox qui ne se suivent pas

Résolu
Bonjour,

J'aimerais savoir si il est possible de faire une boucle sur des textbox qui ne se suivent pas?

J'ai essayé avec Controls("Textbox" & i) mais je ne sais pas comment faire pour passer du textbox 2 au 6 puis au10, ...

Voici mon code :

If TextBox2.Value < TextBox5.Value Then
MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
Exit Sub
End If

If TextBox6.Value < TextBox9.Value Then
MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
Exit Sub
End If

If TextBox10.Value < TextBox13.Value Then
MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
Exit Sub
End If

If TextBox14.Value < TextBox17.Value Then
MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
Exit Sub
End If

If TextBox18.Value < TextBox21.Value Then
MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
Exit Sub
End If

If TextBox22.Value < TextBox25.Value Then
MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
Exit Sub
End If

Merci pour vos retours

1 réponse

  1. Bonjour,
    Pourquoi faire une boucle, vous n'avez qu'un message.

    If (TextBox2.Value < TextBox5.Value) OR (TextBox10.Value < TextBox13.Value) OR .............Then
    MsgBox "Votre stock Tampon est superieur à Stock !", vbExclamation, "ATTENTION"
    Exit Sub
    end if

    Bonne suite
    0
    1. c'est vrai, j'ai cherché à faire compliqué alors que c'était simple.

      merci pour ce retour
      0