1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Sub Patch_TXT()
Dim Mois_string As String
Dim Jour_string As String
Dim Heure_string As String
Dim Minute_string As String
Dim LaLigne As String
Dim Mois_pos As Long
Dim Jour_pos As Long
Dim Heure_pos As Long
Dim Minute_pos As Long
Dim Input_file As String
Dim Output_File As String
Mois_string = "Mois ecoule : "
Jour_string = "Jours ecoule : "
Heure_string = "Heures ecoule : "
Minute_string = "Mois ecoule : "
Input_file = "nom complet du fichier en input.txt"
Output_File = "nom complet du fichier en output TEMPORAIRE.txt"
Open Input_file For Input As #1
Open Output_File For Output As #2
Do While Not EOF(1)
Line Input #1, LaLigne
Mois_pos = InStr(1, LaLigne, Mois_string, vbTextCompare)
Jour_pos = InStr(1, LaLigne, Jour_string, vbTextCompare)
Heure_pos = InStr(1, LaLigne, Heure_string, vbTextCompare)
Minute_pos = InStr(1, LaLigne, Minute_string, vbTextCompare)
Select Case True
Case Mois_pos > 0
Mid(LaLigne, Mois_pos + Len(Mois_string), 2) = Month(Now())
Case Jour_pos > 0
Mid(LaLigne, Jour_pos + Len(Jour_string), 2) = Day(Now())
Case Heure_pos > 0
Mid(LaLigne, Heure_pos + Len(Heure_string), 2) = Hour(Now())
Case Minute_pos > 0
Mid(LaLigne, Minute_pos + Len(Minute_string), 2) = Minute(Now())
End Select
Print #2, LaLigne
Loop
Close #1
Close #2
Kill Input_file
Name Output_File As Input_file
End Sub |
Partager