OVH Cloud OVH Cloud

problème de virgule dans un fichier text

1 réponse
Avatar
Emcy
Bonjours,

J'essaye de récupérer des lignes dans un fichier text mais le problème est
que lorsque j'ai une virgule dans ma ligne, ma macro me detect un retour à
la ligne : que dois-je faire ?

Sub LoadFichierText(FichierIni As String)

Dim MaLigneIni As String

If Dir(FichierIni) <> "" Then

On Error GoTo ErreurIniCartouche
Open FichierIni For Input As #1

i = 1

Do Until EOF(1)
Input #1, MaLigneIni

Select Case i
Case 5
Me.TextBoxEquipe.Value = MaLigneIni

Case 8
Me.TextBoxNU.Value = MaLigneIni

Case 11
Me.TextBoxDesignation.Value = MaLigneIni

Case 14
Me.TextBoxIND1.Value = MaLigneIni
Case 15
Me.TextBoxIND2.Value = MaLigneIni
Case 16
Me.TextBoxIND3.Value = MaLigneIni
Case 17
Me.TextBoxIND4.Value = MaLigneIni

Case 20
Me.TextBoxDate1.Value = MaLigneIni
Case 21
Me.TextBoxDate2.Value = MaLigneIni
Case 22
Me.TextBoxDate3.Value = MaLigneIni
Case 23
Me.TextBoxDate4.Value = MaLigneIni

Case 26
Me.TextBoxObjet1.Value = MaLigneIni
Case 27
Me.TextBoxObjet2.Value = MaLigneIni
Case 28
Me.TextBoxObjet3.Value = MaLigneIni
Case 29
Me.TextBoxObjet4.Value = MaLigneIni

Case 32
Me.TextBoxAuteur1.Value = MaLigneIni
Case 33
Me.TextBoxAuteur2.Value = MaLigneIni
Case 34
Me.TextBoxAuteur3.Value = MaLigneIni
Case 35
Me.TextBoxAuteur4.Value = MaLigneIni

Case 38
Me.TextBoxVerif1.Value = MaLigneIni
Case 39
Me.TextBoxVerif2.Value = MaLigneIni
Case 40
Me.TextBoxVerif3.Value = MaLigneIni
Case 41
Me.TextBoxVerif4.Value = MaLigneIni
End Select

i = i + 1
Loop
Close #1

End If

Exit Sub

ErreurIniCartouche:
MsgBox ("Erreur de lecture sur le fichier : " + FichierText)
End

End Sub

End Sub

1 réponse

Avatar
Clément Marcotte
Bonjour,

Remplace input #1, par lineinput #1,


--
On apprend pas à un vieux singe à faire des grimaces
"Emcy" a écrit dans le message de
news:
Bonjours,

J'essaye de récupérer des lignes dans un fichier text mais le
problème est

que lorsque j'ai une virgule dans ma ligne, ma macro me detect un
retour à

la ligne : que dois-je faire ?

Sub LoadFichierText(FichierIni As String)

Dim MaLigneIni As String

If Dir(FichierIni) <> "" Then

On Error GoTo ErreurIniCartouche
Open FichierIni For Input As #1

i = 1

Do Until EOF(1)
Input #1, MaLigneIni

Select Case i
Case 5
Me.TextBoxEquipe.Value = MaLigneIni

Case 8
Me.TextBoxNU.Value = MaLigneIni

Case 11
Me.TextBoxDesignation.Value = MaLigneIni

Case 14
Me.TextBoxIND1.Value = MaLigneIni
Case 15
Me.TextBoxIND2.Value = MaLigneIni
Case 16
Me.TextBoxIND3.Value = MaLigneIni
Case 17
Me.TextBoxIND4.Value = MaLigneIni

Case 20
Me.TextBoxDate1.Value = MaLigneIni
Case 21
Me.TextBoxDate2.Value = MaLigneIni
Case 22
Me.TextBoxDate3.Value = MaLigneIni
Case 23
Me.TextBoxDate4.Value = MaLigneIni

Case 26
Me.TextBoxObjet1.Value = MaLigneIni
Case 27
Me.TextBoxObjet2.Value = MaLigneIni
Case 28
Me.TextBoxObjet3.Value = MaLigneIni
Case 29
Me.TextBoxObjet4.Value = MaLigneIni

Case 32
Me.TextBoxAuteur1.Value = MaLigneIni
Case 33
Me.TextBoxAuteur2.Value = MaLigneIni
Case 34
Me.TextBoxAuteur3.Value = MaLigneIni
Case 35
Me.TextBoxAuteur4.Value = MaLigneIni

Case 38
Me.TextBoxVerif1.Value = MaLigneIni
Case 39
Me.TextBoxVerif2.Value = MaLigneIni
Case 40
Me.TextBoxVerif3.Value = MaLigneIni
Case 41
Me.TextBoxVerif4.Value = MaLigneIni
End Select

i = i + 1
Loop
Close #1

End If

Exit Sub

ErreurIniCartouche:
MsgBox ("Erreur de lecture sur le fichier : " + FichierText)
End

End Sub

End Sub