CodeItBetter Programming Another VB Programming Blog

How to Kills Html Tags

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'Miscellaneous - How to Kills Html Tags
Public Function KillHTML(ByVal strIn As String) As String
    Dim lngLen As Long, lngFound As Long, lngEnd As Long
    Dim strLeft As String, strRight As String
    strIn$ = Replace(strIn$, "<HTML>", "")
    strIn$ = Replace(strIn$, "</HTML>", "")
    strIn$ = Replace(strIn$, "<SUP>", "")
    strIn$ = Replace(strIn$, "</SUP>", "")
    strIn$ = Replace(strIn$, "<HR>", "")
    strIn$ = Replace(strIn$, "<H1>", "")
    strIn$ = Replace(strIn$, "<H2>", "")
    strIn$ = Replace(strIn$, "<H3>", "")
    strIn$ = Replace(strIn$, "<PRE>", "")
    strIn$ = Replace(strIn$, "

", "")
strIn$ = Replace(strIn$, " strIn$ = Replace(strIn$, "", "")
strIn$ = Replace(strIn$, "
", "")
strIn$ = Replace(strIn$, "", "")
strIn$ = Replace(strIn$, "
", "")
strIn$ = Replace(strIn$, "", "")
strIn$ = Replace(strIn$, "
", "")
strIn$ = Replace(strIn$, "", "")
strIn$ = Replace(strIn$, "
", "")
strIn$ = Replace(strIn$, "", "")
strIn$ = Replace(strIn$, "", "")
strIn$ = Replace(strIn$, "
", "")
strIn$ = Replace(strIn$, "", "")
lngLen& = Len(strIn$)
lngFound& = InStr(strIn$, " Do While lngFound& <> 0
lngEnd& = InStr(lngFound&, strIn$, ">")
If lngEnd& <> 0 Then
strLeft$ = Left(strIn$, lngFound& - 1)
strRight$ = Right(strIn$, lngLen& - lngEnd&)
strIn$ = strLeft$ & strRight$
lngLen& = Len(strIn$)
End If
lngFound& = InStr(lngFound& + 1, strIn$, " Loop
lngFound& = InStr(strIn$, " Do While lngFound& <> 0
lngEnd& = InStr(lngFound&, strIn$, ">")
If lngEnd& <> 0 Then
strLeft$ = Left(strIn$, lngFound& - 1)
strRight$ = Right(strIn$, lngLen& - lngEnd&)
strIn$ = strLeft$ & strRight$
lngLen& = Len(strIn$)
End If
lngFound& = InStr(lngFound& + 1, strIn$, "
Loop
lngFound& = InStr(strIn$, " Do While lngFound& <> 0
lngEnd& = InStr(lngFound&, strIn$, ">")
If lngEnd& <> 0 Then
strLeft$ = Left(strIn$, lngFound& - 1)
strRight$ = Right(strIn$, lngLen& - lngEnd&)
strIn$ = strLeft$ & strRight$
lngLen& = Len(strIn$)
End If
lngFound& = InStr(lngFound& + 1, strIn$, " Loop
strIn$ = Replace(strIn$, "&", "&")
strIn$ = Replace(strIn$, "<", "<")
KillHTML$ = strIn$
End Function

'or

Function RemoveHTML(strHTML As String) As String
Do
tagOpen = InStr(1, strHTML, "<")
tagClose = InStr(1, strHTML, ">")
strHTML = Replace(strHTML, Mid(strHTML, tagOpen, tagClose - tagOpen + 1), "")
Debug.Print strHTML
Loop Until InStr(1, strHTML, "<") = 0
RemoveHTML = strHTML
End Function

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.