recherche chaine de caractere
Bonjour,
J'ai realiser un programme qui permet de choisir un fichier sur le disque dur et ensuite des qu il rencontre un <td> il saute la ligne.
Mon probleme c est qu'il reconnait sous cette forme <td> mais des que c est <td width="414"> par exemple il ne reconnait plus.Je me demandais si il y avait une fonction qui pemettrais de dire que des qu il trouve <td au debut et > a la fin qu il puissent prendre tt cette chaine de caractere afin de faire le saut de ligne.
Voici le bout de code au niveau de la recherche:
Code:
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
|
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, i, j, k, strtmp, Resultat
Set fso = CreateObject("Scripting.FileSystemObject")
Dim objTextStream 'objet contenant le texte a modifier,pour chaque modif ouvrir le fichier en lecture et ecriture
'on lis le fichier corespondant pour modifier les td
Set objTextStream = Fso.OpenTextFile(fichier, ForReading)
Resultat = objTextStream.ReadAll
strtmp = split(Resultat,"")
For j = 0 to Ubound(strtmp)
If instr(trim(strtmp(j)),"<td>") Then
strtmp(j) = Replace(strtmp(j),"<td>","<td>" & vbcrlf & vbtab & vbtab )
End If
objTextStream.Close
Set objTextStream = Fso.OpenTextFile(fichier, ForWriting, True)
objTextStream.Write strtmp(j)
objTextStream.Close
Next
'on lis le fichier corespondant pour modifier les td
Set objTextStream = Fso.OpenTextFile(fichier, ForReading)
Resultat = objTextStream.ReadAll
strtmp = split(Resultat,"")
For k = 0 to Ubound(strtmp)
If instr(trim(strtmp(k)),"</td>") Then
strtmp(k) = Replace(strtmp(k),"</td>",vbcrlf & vbtab & vbtab &"</td>")
End If
objTextStream.Close
Set objTextStream = Fso.OpenTextFile(fichier, ForWriting, True)
objTextStream.Write strtmp(k)
objTextStream.Close
Next
Set objTextStream = Nothing
Set fso = Nothing
MsgBox "Modifications effectuées !!!", vbInformation, Now() |
Pour plus de precision n 'hesiter pas a me demander
merci d avance