VBA Import fichier texte dans une ListBox

mdeg Messages postés 28 Date d'inscription mercredi 31 mars 2010 Statut Membre Dernière intervention 29 avril 2010 - 31 mars 2010 à 21:01
bouchaibkiki Messages postés 2 Date d'inscription lundi 7 juin 2010 Statut Membre Dernière intervention 20 décembre 2010 - 20 déc. 2010 à 22:12
Bonjour,

Je souhaite afficher dans une listebox le contenu d'un fichier txt du type

1;1000.000;5000.000;100.000;500.000
2;1002.000;5000.000;100.000;500.000
3;1003.000;5000.000;100.000;500.000
4;1004.000;5000.000;100.000;500.000

J'ai créer le code suivant
Private Sub CommandButton_Ouvrir_Click()

Dim Fichier

Fichier = Application.GetOpenFilename("Fichier Texte (*.txt), *.txt")
If Fichier = False Then Exit Sub
If Fichier Like "*" & ThisWorkbook.Name Then MsgBox "Ouverture non autorisée.": Exit Sub
On Error Resume Next
Open Fichier For Input As #1
On Error GoTo 0

Dim Ligne As String
Dim Valeur As Variant
Dim Separateur As String

Input #1, Ligne
Separateur = InputBox("Entrer le séparateur de données : " & Ligne, "Séparateur")

While Not (EOF(1))
Input #1, Ligne
Valeur = Split(Ligne, Separateur)
ListBox_Points_Homologues.AddItem (Valeur(0))
ListBox_Points_Homologues.List(ListBox_Points_Homologues.ListCount - 1, 1) = Valeur(1)
ListBox_Points_Homologues.List(ListBox_Points_Homologues.ListCount - 1, 2) = Valeur(2)
ListBox_Points_Homologues.List(ListBox_Points_Homologues.ListCount - 1, 3) = Valeur(3)
ListBox_Points_Homologues.List(ListBox_Points_Homologues.ListCount - 1, 4) = Valeur(4)
Wend
Close #1

End Sub


Le probléme lorsque je l'execute est qu'il me manque la première ligne du fichier texte dans la listbox.

Est ce que quelqu'un pourrait m'aider à résoudre ce probléme?

Merci,

Mdeg

1 réponse

bouchaibkiki Messages postés 2 Date d'inscription lundi 7 juin 2010 Statut Membre Dernière intervention 20 décembre 2010
20 déc. 2010 à 22:12
[^^langue3]
0
Rejoignez-nous