Strip HTML

By | 2002-06-01

Strip HTML from a string with this function. That basically explains it’s all!!

Original Author: DoWnLoHo

Code

Public Function StripHTML(sHTML As String) As String
Dim sTemp As String, lSpot1 As Long, lSpot2 As Long, lSpot3 As Long
sTemp$ = sHTML$
Do
lSpot1& = InStr(lSpot3& + 1, sTemp$, "<")
lSpot2& = InStr(lSpot1& + 1, sTemp$, ">")

  If lSpot1& = lSpot3& Or lSpot1& < 1 Then Exit Do
  If lSpot2& < lSpot1& Then lSpot2& = lSpot1& + 1
  
sTemp$ = Left$(sTemp$, lSpot1& - 1) + Right$(sTemp$, Len(sTemp$) - lSpot2&)
lSpot3& = lSpot1& - 1
Loop
StripHTML$ = sTemp$
End Function

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.