Liste à plusieurs colonnes vb6 combobox, listbox...

Résolu
AndreBourvil Messages postés 15 Date d'inscription dimanche 27 juillet 2003 Statut Membre Dernière intervention 1 mars 2013 - 30 mars 2009 à 13:53
AndreBourvil Messages postés 15 Date d'inscription dimanche 27 juillet 2003 Statut Membre Dernière intervention 1 mars 2013 - 30 mars 2009 à 20:57
Bonjour,

J'essaie de faire (en plus d'une recherche par nom) une liste multiple composée des nom et prénom du client ainsi que du numéro de facture comme ci-après:  DUPONT Henri Facture N° 142

L'ajout, la suppression, la modification ainsi que la lecture se fait bien losrque ma liste est limitée à 1 seul champ (nom ou prénom par exemple) mais lors-ce-qu'elle est multiple, à l'initialisation (plus bas) les valeurs de tous mes champs concernant le client et  la facture n'apparaissent pas (comme s'il y avait un  problème d'indexation)
Par contre, ma liste affiche bien les champs demandés:     liste_nom.AddItem Trim(VarEnreg.ChampNom) '& " " &
Trim(VarEnreg.ChampPrénom) & " " & "-" & " " & "Facture
N°" & " " & Trim(NumEnreg) (DUPONT Henri Facture N° 142)

Private Sub btn_ajouter_Click()
Dim p As Integer
Open App.Path & "\FACTURES.tba" For Random Access Read Write As #1 Len = Len(VarEnreg)

NumRows = LOF(1) \ Len(VarEnreg)
                         
If txt_nom = "" Then
            frm_aide.Show
            frm_aide.lbl_aide_titre.Caption = "NOUVELLE FACTURE"
            frm_aide.lbl_aide.Caption = "Vous devez renseigner le nom du client !"
Else
If txt_adresse = "" Then
            frm_aide.Show
            frm_aide.lbl_aide_titre.Caption = "NOUVELLE FACTURE"
            frm_aide.lbl_aide.Caption = "Vous devez renseigner l'adresse du client !"
Else
If txt_ville = "" Then
            frm_aide.Show
            frm_aide.lbl_aide_titre.Caption = "NOUVELLE FACTURE"
            frm_aide.lbl_aide.Caption = "Vous devez renseigner la ville du client !"
Else
If txt_code_postal = "" Then
            frm_aide.Show
            frm_aide.lbl_aide_titre.Caption = "NOUVELLE FACTURE"
            frm_aide.lbl_aide.Caption = "Vous devez renseigner le code postal du client !"
Else

If txt_forme_juridique = "" Then
            frm_aide.Show
            frm_aide.lbl_aide_titre.Caption = "NOUVELLE FACTURE"
            frm_aide.lbl_aide.Caption = "Vous devez renseigner la forme juridique du client !"

Else

                            For p = 0 To 16
                                    VarEnreg.ChampMontant(p) = txt_montant(p)
                                    VarEnreg.ChampQuantite(p) = txt_quantite(p)
                                    VarEnreg.ChampPrixUnitaire(p) = txt_prix_unitaire(p)
                                    VarEnreg.Champ_ProduitPrestation(p) =                   txt_poduit_prestation(p)
                            Next p
                                    VarEnreg.ChampDate = lbl_date
                                    VarEnreg.ChampTVA = txt_tva
                                    VarEnreg.ChampMontantHT = txt_total_hors_taxe
                                    VarEnreg.ChampTotalChampTVA = txt_total_tva
                                    VarEnreg.ChampMontantTTC = txt_total_ttc
                     
                                    VarEnreg.ChampPrénom = txt_prenom
                                    VarEnreg.ChampAdresse = txt_adresse
                                    VarEnreg.ChampVille = txt_ville
                                    VarEnreg.ChampCodePostal = txt_code_postal
                                    VarEnreg.ChampEmail = txt_email
                                    VarEnreg.ChampNom = txt_nom
                                    VarEnreg.ChampPortable = txt_portable
                                    VarEnreg.ChampTelephone = txt_telephone
                                    VarEnreg.ChampFormeJuridique = txt_forme_juridique
                                    VarEnreg.ChampRemarque = txt_remarque
                                      
                                    VarEnreg.ChampQte = lbl_quantite
                                    VarEnreg.ChampPrix = p
                                    VarEnreg.ChampMontantTHT = lbl_montant_hors_taxe
                                    VarEnreg.ProduitPrestation = lbl_produit_prestation
                                    'Put c'est pour ajouter les infos txt_nom, txt_prenom, ... dans le fichier #1
                                    Put #1, NumRows + 1, VarEnreg

                                    txt_nom = ""
                                    txt_prenom = ""
                                    txt_adresse = ""
                                    txt_ville = ""
                                    txt_code_postal = ""
                                    txt_telephone = ""
                                    txt_portable = ""
                                    txt_email = ""
                                    txt_forme_juridique = ""
                                    txt_numero = ""
                                    txt_remarque = ""
                                    txt_code_client = ""

                            For g = 0 To 16
                                    txt_montant(g) = ""
                                    txt_quantite(g) = ""
                                    txt_prix_unitaire(g) = ""
                                    txt_poduit_prestation(g) = ""
                            Next g
                                    lbl_date.Caption = ""
                                    txt_total_hors_taxe.Text = ""
                                    txt_tva.Text = ""
                                    txt_total_tva.Text = ""
                                    txt_total_ttc.Text = ""
                                    txt_nom.SetFocus
    
    
            frm_aide.Show
            frm_aide.lbl_aide_titre.Caption = "ENREGISTREMENT"
            frm_aide.lbl_aide.Caption = "La facture a bien été enregistrée !"

    End If
    End If
    End If
    End If
    End If

Close #1

Open App.Path & "\FACTURES.tba" For Random Access Read As #1 Len = Len(VarEnreg)

NumRows = LOF(1) \ Len(VarEnreg)
liste_nom.Clear
For i = 1 To NumRows
Get #1, i, VarEnreg
    liste_nom.AddItem Trim(VarEnreg.ChampNom) '& " " & Trim(VarEnreg.ChampPrénom) & " " & "-" & " " & "Facture N°" & " " & Trim(NumEnreg)
Next i

For i = 1 To NumRows
Get #1, i, VarEnreg
Next i
Close #1

End Sub

Je vous remercie de m'éclairer s'il vous plaît.

@pluche

Nadia

2 réponses

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
30 mars 2009 à 14:14
pourquoi ne pas utiliser un ListView ?

c'est simple a utiliser, et adapté a ton cas
3
AndreBourvil Messages postés 15 Date d'inscription dimanche 27 juillet 2003 Statut Membre Dernière intervention 1 mars 2013
30 mars 2009 à 20:57
Bonsoir,

Merci pour ta réponse, je vais essayer. A vrai dire je croyais que le ListView était "réservé" au objets mais pas pour le texte.

@+

Nadia
0
Rejoignez-nous