Si texbox1 est remplie alors textbox2

geraldvc Messages postés 13 Date d'inscription jeudi 23 août 2007 Statut Membre Dernière intervention 22 décembre 2008 - 21 déc. 2008 à 20:43
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 - 22 déc. 2008 à 16:44
Hello je voudrais transferer une textboxA dans un autre textbox1 MAIS si elle est remplie allez a la textbox2 et si elle est remplie allez en textbox3 ansi de suite, j'ai 14 textbox
Bien à Vous [mailto:geraldvc@gmail.com geraldvc@gmail.com]

10 réponses

cs_Exploreur Messages postés 4821 Date d'inscription lundi 11 novembre 2002 Statut Membre Dernière intervention 15 novembre 2016 15
21 déc. 2008 à 22:01
Salut,

Voici un petit exemple à travailler ^^ :

Private Sub Command1_Click()


If Text1.Text = vbNullString Then
   Text1.Text = TextBoxA.Text
   Exit Sub
ElseIf Text2.Text = vbNullString Then
   Text2.Text = TextBoxA.Text
   Exit Sub
ElseIf Text3.Text = vbNullString Then
   Text3.Text = TextBoxA.Text
   Exit Sub
Else
   MsgBox "Erreur, toutes les zones de saisie sont remplies !"
End If


End Sub


A+
Exploreur

 Linux a un noyau, Windows un pépin
0
geraldvc Messages postés 13 Date d'inscription jeudi 23 août 2007 Statut Membre Dernière intervention 22 décembre 2008
22 déc. 2008 à 07:34
merci je fait des essai et je vous tiens au courant
0
geraldvc Messages postés 13 Date d'inscription jeudi 23 août 2007 Statut Membre Dernière intervention 22 décembre 2008
22 déc. 2008 à 08:00
Après un essai, je peux voir la donnée est transferée la premiere fois en textbox1 et la donnée suivente ne va pas en textbox2. Elle n'est pas inscrite  ,Donc quand il y a la donnée dans la textbox1 il ne va pas l'inscrire dans la textbox2  ?
Merci
0
geraldvc Messages postés 13 Date d'inscription jeudi 23 août 2007 Statut Membre Dernière intervention 22 décembre 2008
22 déc. 2008 à 08:12
Ok elle fonctionne je l'avais mis dans le code de la textbox et maitenant je l'ai sur un bonton clic

Merci mille foissss
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
NHenry Messages postés 15112 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 13 avril 2024 159
22 déc. 2008 à 09:53
Bonjour,

Regarde aussi la propriété Index des controles, elle te permettra de faire une boucle correcte, simple et concis.

http://nhen0039.chez-alice.fr/index.php
0
cs_Exploreur Messages postés 4821 Date d'inscription lundi 11 novembre 2002 Statut Membre Dernière intervention 15 novembre 2016 15
22 déc. 2008 à 09:54
Re,

Petite question.....Est-ce que tes TextBox sont indéxés ? Car cela pourrait simplifier le code....comme :

Private Sub Command1_Click()


For i = 0 To 5    If Text1(i).Text vbNullString Then Text1(i).Text "Toto": Exit For
Next i


End Sub


A+
Exploreur

 Linux a un noyau, Windows un pépin
    ** http://exploreur1.labrute.fr **
0
geraldvc Messages postés 13 Date d'inscription jeudi 23 août 2007 Statut Membre Dernière intervention 22 décembre 2008
22 déc. 2008 à 13:13
Nouvelle difficulter enfin pour moi!!!


Le principe est : Texbox1,Combobox1,Textbox2,Textebox3, doivent être inscrite, dans la feuil2 dans une listbox1 et dans mes Textebox nommée nbr1 nbr2 ainsi de suite jusque 14 et idem pour Combobox1,Textbox2,Textebox3.



 En espèrent que vous m’avez compris.



<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" /??>
 




Car de ce ça si j’arrive qu’elles s’inscrivent dans l’un ou dans l’autre mais pas tout !!!








Private Sub Enregistré_Click() 'Bibliothèque
   
   Dim Nb As Integer, Dnb As Integer, i As Integer, Y As String
    Dim Element_Select As String
    Dnb = Sheets("feuil2").Range("E2").Value
    Nb = UserForm2.ListBox1.ListCount
    Element_Select = False
    Sheets("feuil2").Activate
    Y = 3 'Sur Feuil2 ligne de départ de la bibli ----> "A3"
  
  For i = 0 To Nb - 1
    If UserForm2.ListBox1.Selected(i) = True Then
        Element_Select = True
        Range("a" & i + Y).Value = TextBox1
        Range("b" & i + Y).Value = ComboBox1
        Range("c" & i + Y).Value = TextBox2
        Range("d" & i + Y).Value = TextBox1
        With Range("d" & i + Y)
            .HorizontalAlignment = xlHAlignRight
            .VerticalAlignment = xlVAlignCenter
                With .Font
                    .Size = 8
                    .Italic = False
                    .Bold = False
                    .Name = "Arial"
                End With
        End With
    End If
Next


If Element_Select = False Then
    Range("a" & Dnb + Y).Value = TextBox1
    Range("b" & Dnb + Y).Value = ComboBox1
    Range("c" & Dnb + Y).Value = TextBox2
    Range("d" & Dnb + Y).Value = TextBox3
    With Range("d" & i + Y)
            .HorizontalAlignment = xlHAlignRight
            .VerticalAlignment = xlVAlignCenter
    End With
    Dnb = Dnb + 2
    ElseIf TextBox2 = "" Then
        Dnb = Dnb - 1
        For J = 0 To Nb + 3
            If "" = Range("b" & J + Y).Value Then 'supprime ligne vide
                Range("b" & J + Y).Select
                For X = -1 To 2
                    Range("b" & J + Y).Offset(0, X) = Range("b" & J + Y).Offset(1, X).Value
                    Range("b" & J + Y).Offset(1, X).Value = Clear
                Next
            End If
        Next
    Else
End If
    TextBox1 = Clear
    ComboBox1 = Clear
    TextBox2 = Clear
    TextBox3 = Clear
    Call box1
    Dnb = Sheets("feuil2").Range("E2").Value




'transfert nbr
  If nbr1.Text = vbNullString Then
   nbr1.Text = TextBox1.Text
   Exit Sub
ElseIf nbr2.Text = vbNullString Then
   nbr2.Text = TextBox1.Text
   Exit Sub
ElseIf nbr3.Text = vbNullString Then
   nbr3.Text = TextBox1.Text
   Exit Sub
ElseIf nbr4.Text = vbNullString Then
   nbr4.Text = TextBox1.Text
   Exit Sub
ElseIf nbr5.Text = vbNullString Then
   nbr5.Text = TextBox1.Text
   Exit Sub
   ElseIf nbr6.Text = vbNullString Then
   nbr6.Text = TextBox1.Text
   Exit Sub
ElseIf nbr7.Text = vbNullString Then
   nbr7.Text = TextBox1.Text
   Exit Sub
  
   ElseIf nbr8.Text = vbNullString Then
   nbr8.Text = TextBox1.Text
   Exit Sub
ElseIf nbr9.Text = vbNullString Then
   nbr9.Text = TextBox1.Text
   Exit Sub
   ElseIf nbr10.Text = vbNullString Then
   nbr10.Text = TextBox1.Text
   Exit Sub
ElseIf nbr11.Text = vbNullString Then
   nbr11.Text = TextBox1.Text
   Exit Sub
   ElseIf nbr12.Text = vbNullString Then
   nbr12.Text = TextBox1.Text
   Exit Sub
ElseIf nbr13.Text = vbNullString Then
   nbr13.Text = TextBox1.Text
   Exit Sub
   ElseIf nbr14.Text = vbNullString Then
   nbr14.Text = TextBox1.Text
   Exit Sub
   'fransfert article
   If article1.Text = vbNullString Then
   article1.Text = ComboBox1.Text
   Exit Sub
ElseIf article2.Text = vbNullString Then
   article2.Text = ComboBox1.Text
   Exit Sub
ElseIf article3.Text = vbNullString Then
   article3.Text = ComboBox1.Text
   Exit Sub
ElseIf article4.Text = vbNullString Then
   article4.Text = ComboBox1.Text
   Exit Sub
ElseIf article5.Text = vbNullString Then
   article5.Text = ComboBox1.Text
   Exit Sub
   ElseIf article6.Text = vbNullString Then
   article6.Text = ComboBox1.Text
   Exit Sub
ElseIf article7.Text = vbNullString Then
   article7.Text = ComboBox1.Text
   Exit Sub
  
   ElseIf article8.Text = vbNullString Then
   article8.Text = ComboBox1.Text
   Exit Sub
ElseIf article9.Text = vbNullString Then
   article9.Text = ComboBox1.Text
   Exit Sub
   ElseIf article10.Text = vbNullString Then
   article10.Text = ComboBox1.Text
   Exit Sub
ElseIf article11.Text = vbNullString Then
   article11.Text = ComboBox1.Text
   Exit Sub
   ElseIf nbr12.Text = vbNullString Then
   article12.Text = ComboBox1.Text
   Exit Sub
ElseIf article13.Text = vbNullString Then
   article13.Text = ComboBox1.Text
   Exit Sub
   ElseIf article14.Text = vbNullString Then
   article14.Text = ComboBox1.Text
   Exit Sub
  
  
  
If Element_Select = True Then
    For i = 0 To ListBox1.ListCount - 1
        ListBox1.Selected(i) = False
        TextBox1 = Clear
        ComboBox1 = Clear
        TextBox2 = Clear
        TextBox2 = Clear
    Next i
    MsgBox "Toutes les zones de saisie sont remplies !"
   Else
     End If
   End If
End If
End Sub
0
cs_Exploreur Messages postés 4821 Date d'inscription lundi 11 novembre 2002 Statut Membre Dernière intervention 15 novembre 2016 15
22 déc. 2008 à 16:17
Salut,

Déjà(c'est une remarque hein ^^) commence par indéxés tes contrôles pour que ton code soit plus "lisible" est plus court....on y vera mieux.....

A+
Exploreur

 Linux a un noyau, Windows un pépin
    ** http://exploreur1.labrute.fr **
0
geraldvc Messages postés 13 Date d'inscription jeudi 23 août 2007 Statut Membre Dernière intervention 22 décembre 2008
22 déc. 2008 à 16:25
oui mais comment faire? je sais pas comment indexer!! dit moi comment
Merci tu est sympa d'y jeter un oiel
0
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
22 déc. 2008 à 16:44
Autre remarque en passant : si une réponse a été validée, il ne sert à rien de reposer une question, car le topic sera marqué comme "résolu" dans le forum. Plus personne ne viendra regarder ...

Pour l'indexation, dépose une textbox sur ton formulaire. Passe sa propriété Index à 0.
Puis copie la textbox, et colle la X fois sur le formulaire. Tu verras apparaître des textbox identiques, mais dont la propriété Index s'est incrémentée. Tu pourras alors utiliser nomDeMaTexbox(indice) pour en pointer une. Et faire des boucles, ce qui te facilitera la vie.

Manu
--------------------------------------------------------------
Avant de poster un message, n'oubliez pas de consulter le reglement.
0
Rejoignez-nous