holas aka les dejo este pequeño code. que lo empece haciendo para una pagina en otro idioma y se me ocurrió traducirlo. Lo que hace es extraer el texto que se encuentre entre '<font>' y '</font>.
En un modulo:
Public Sub ExtractText(ByVal strData As String, ByRef strArrayOut() As String)
Dim strText() As String: ReDim strText(0) As String
Dim strBuf As String
Dim bol As Boolean: bol = False
strBuf = strData
Do While Not bol
If InStr(LCase(strBuf), "<font") > 0 Then
strBuf = Mid(strBuf, InStr(LCase(strBuf), "<font"))
If InStr(LCase(strBuf), ">") > 0 Then
Dim inta As Integer: inta = InStr(LCase(strBuf), ">")
If InStr(LCase(strBuf), "</font") > 0 Then
Dim intb As Integer
intb = InStr(LCase(strBuf), "</font") - inta
PlusArray strText, Mid(strBuf, inta + 1, intb - 1)
strBuf = Mid(strBuf, inta)
Else
bol = True
End If
Else
bol = True
End If
Else
bol = True
End If
Loop
ReDim strArrayOut(UBound(strText)) As String
strArrayOut = strText
End Sub
Public Sub PlusArray(ByRef strArray() As String, ByVal strPlus As String)
Dim lngP As Long
lngP = UBound(strArray) + 1
ReDim Preserve strArray(lngP)
strArray(lngP) = strPlus
End Sub
Y para probarlo en un form:
Private Sub Form_Load()
Dim x As Integer
Dim strText As String
Dim strArrayText() As String
strText = "<font > el electrodo magico </font><font > mucha variedad en electrodos </font> <font > electrodo automatico </font> <font > un pedo </font>"
ExtractText strText, strArrayText
Me.Print "Prueba:"
Me.Print ""
Me.Print ""
For x = 0 To UBound(strArrayText)
Me.Print " " & strarraytext(x)
Next
End Sub
Bue no se, se puede usar si quieres hacer una búsqueda en una web.
54¬U|)()5
estas haciendo cagadas, mira cuantas lineas al dope.
asi vas a hacer errores (creeria que no) y/o tardar mucho
usa la funcion TEXTINBETWINE (de cobein, pero le pegue una modificacion yo)
Public Function TextInBetwinE(ByVal sData As String, ByVal sStart As String, ByVal sEnd As String) As String
If InStr(sData, sStart) > 0 Then
sData = Mid(sData, InStr(sData, sStart) + Len(sStart))
TextInBetwinE = Mid(sData, 1, InStr(sData, sEnd) - 1)
End If
End Function
tene cuidado, si no existe el tag de cerrado, va a tirar error
la funcion trabaja asi:
encuentra la primer coincidencia, y hace que llegue hasta la primer coincidencia final
llama a la funcion asi
TextInBetwinE("<font > el electrodo magico </font><font > mucha variedad en electrodos </font> <font > electrodo automatico </font> <font > un pedo </font>", "<font >", "</font>")
eso te devuelve el primer tag..
para sacar el segundo tag, hace un replace a la cadena original, sacando el tag actual y hace asi hasta q no haya mas tags
saludos