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
| Option Explicit
Private Sub Command1_Click()
Dim FF As Integer, fic_a_traiter As String, strtext As String, nellechaine As String, pos As Integer, encours As String ', tremp As String
FF = FreeFile
fic_a_traiter = "d:\essai.txt" 'mets ici le nom (xxxx.frm, ssss.bas, etc... par exemple)
Open fic_a_traiter For Input As #FF
strtext = Input(LOF(FF), #FF)
Close #FF
nellechaine = ""
Do While Len(strtext) > 0
pos = InStr(strtext, "Print #")
If pos > 0 Then
nellechaine = nellechaine & Left(strtext, pos - 1) & "Print #"
encours = calcule_encours(Mid(strtext, pos + 7))
strtext = Mid(strtext, pos + Len(encours) + 7)
nellechaine = nellechaine & encours & vbNewLine & "Debug.print " & Mid(encours, InStr(encours, ",") + 1)
Else
nellechaine = nellechaine & strtext
Exit Do
End If
Loop
FF = FreeFile
Open fic_a_traiter For Output As #FF
Print #FF, nellechaine
Close #FF
End Sub
Private Function calcule_encours(quoi As String) As String
Dim pos As Integer
pos = InStr(quoi, vbNewLine)
If pos < 0 Then Exit Function
calcule_encours = Left(quoi, pos)
End Function |
Partager