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
|
Public Function testsb()
Dim asRes() As String
Dim i As Integer
asRes = SansBalise("<b>toto</b><b>tata</b>", ">", "<")
Debug.Print UBound(asRes)
For i = 1 To UBound(asRes)
Debug.Print asRes(i)
Next i
End Function
Public Function SansBalise(ByVal sText As String, ByVal sLimGauche As String, _
ByVal sLimDroite As String) As String()
Dim i As Integer, j As Integer, iNbRes As Integer
Dim asResults() As String, sRes As String
i = InStr(sText, sLimGauche)
Do While i > 0
j = InStr(i + 1, sText, sLimDroite)
If j > 0 Then
sRes = Trim$(Mid$(sText, i + 1, j - i - 1))
If sRes <> vbNullString Then
iNbRes = iNbRes + 1
ReDim Preserve asResults(1 To iNbRes)
asResults(iNbRes) = sRes
End If
i = InStr(j + 1, sText, sLimGauche)
Else
Exit Do
End If
Loop
SansBalise = asResults
End Function |
Partager