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
| Dim LeFichier 'pour simuler le contenu du fichier
LeFichier = "<Balise_1>" & vbnewline _
& "<Info_1>Mon info 1</Info_1>" & vbnewline _
& "<Info_2>Mon info 2" & vbnewline _
& "<Info_3>Mon info 3</Info_3>" & vbnewline _
& "Mon info 4</Info_4>" & vbnewline _
& "<Info_5>Mon info 5</Info_5>" & vbnewline _
& "</Balise_1>" & vbnewline _
& "<Balise_1>Mon info 6</Balise_1>"
Dim Memo
Call(Trier)
MsgBox "Balise(s) orpheline(s) " & vbnewline & vbnewline & Memo
'*******************************************************************************
Sub Trier()
Dim Cpt, PosDeb, PosFin, PoS
Dim TblLg, TblCol, BaliseDeb, BaliseFin
TblLg = split(LeFichier,vbnewline)
For Cpt = 0 to Ubound(TblLg)
PosDeb = Instr(1,TblLg(Cpt),"<",0)+ 1
PosFin = Instr(PosDeb,TblLg(Cpt),">",0)
BaliseDeb = Mid(TblLg(Cpt),PosDeb,PosFin-PosDeb)
'MsgBox "BaliseDeb = " & BaliseDeb,,"première recherche"
If Left(BaliseDeb,1) ="/" Then
'MsgBox "balise fermente: " & BaliseDeb
BaliseFin = "<" & BaliseDeb & ">"
BaliseDeb = "<" & replace(BaliseDeb,"/","") & ">"
Pos = InStrRev(LeFichier,BaliseDeb,PosFin,0)
If Pos=0 Then
Memo = Memo & "ligne " & Cpt+1 & ": " & BaliseFin & vbnewline
End If
Else
'MsgBox "balise ouvrente: " & BaliseDeb
BaliseFin = "</" & BaliseDeb & ">"
BaliseDeb = "<" & BaliseDeb & ">"
Pos = Instr(PosFin,LeFichier,BaliseFin,0)
If Pos=0 Then
Memo = Memo & "ligne " & Cpt+1 & ": " & BaliseDeb & vbnewline
End If
End If
Next
End Sub
'******************************************************************************* |
Partager