how would I remove any text in a string that is between "<" and ">"? Im working on removing HTML from a string. Thanks for your help!
Printable View
how would I remove any text in a string that is between "<" and ">"? Im working on removing HTML from a string. Thanks for your help!
I worked on this a little bit, this version only works if all the HTML is correct, so it's not very useful if there are mistakes, and I haven't done a lot of testing, but here:
this removes anything between "<" and ">"Code:Private Function RemoveHTML(strString As String) As String
Dim intStart As Integer
Dim intLength As Integer
Dim intEnd As Integer
Dim strLookFor As String
If InStr(1, strString, "<") <> 0 Then
Do Until InStr(1, strString, "<") = 0
intStart = InStr(1, strString, "<")
If intStart > 0 Then
intEnd = InStr(intStart, strString, ">")
If intEnd > 0 Then
intLength = intEnd - intStart
strlookup = Mid(strString, intStart, intLength + 1)
strString = Replace(strString, strlookup, "")
End If
End If
Loop
End If
RemoveHTML = strString
End Function
'usage
Private Sub Command1_Click()
Text1.Text = RemoveHTML(Text1.Text)
End Sub
let me know if you come up with anything else.