Boucle textbox qui ne se suivent pas

Résolu
eideal Messages postés 25 Statut Membre -  
eideal Messages postés 25 Statut Membre -
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. f894009 Messages postés 17417 Date d'inscription   Statut Membre Dernière intervention   1 717
     
    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. eideal Messages postés 25 Statut Membre
       
      c'est vrai, j'ai cherché à faire compliqué alors que c'était simple.

      merci pour ce retour
      0