1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub TextModif()
Dim TXT As String
Dim TextLine As String
Filename = "D:\Test.txt"
Open Filename For Input As #1 'Ouverture du fichier en lecture.
Do While Not EOF(1)
Line Input #1, TextLine 'Lecture de la ligne
If TextLine = "Ma Valeur" Then TXT = TXT & AjouterText() 'Si le test est concluant j'ajoute mes valeurs dans mon cas A, B, C, D
J
TXT = TXT & TextLine & vbCrLf 'Je concatène mon texte
Loop
Close #1
Open Filename For Output As #1 'Ouverture du fichier en écriture.
Write #1, TXT 'Je stock dans mon fichier la variable TXT
Close #1
End Sub
Function AjouterText() As String
Dim I As Long
For I = 0 To 10
AjouterText = AjouterText & Chr(65 + I) & vbCrLf '65 =A 66=B ...
Next
End Function |
Partager