devxlogo

HTMLDecode – Convert an HTML string to a plain text

' Decode an HTML string to a regular ANSI string'' it strips down all special HTML sequences (eg "<")' however, it doesn't strip HTML tagsFunction HTMLDecode(ByVal html As String) As String    Dim i As Long        HTMLDecode = html        Do        ' search the next ampersand, exit if no more        i = InStr(i + 1, HTMLDecode, "&")        If i = 0 Then Exit Do        If StrComp(Mid$(HTMLDecode, i, 6), " ", vbTextCompare) = 0 Then           HTMLDecode = Left$(HTMLDecode, i - 1) & " " & Mid$(HTMLDecode, i + 6)        ElseIf StrComp(Mid$(HTMLDecode, i, 6), """, vbTextCompare) = 0 Then            HTMLDecode = Left$(HTMLDecode, i - 1) & """" & Mid$(HTMLDecode, _                i + 6)        ElseIf StrComp(Mid$(HTMLDecode, i, 5), "&", vbTextCompare) = 0 Then            HTMLDecode = Left$(HTMLDecode, i - 1) & "&" & Mid$(HTMLDecode, _                i + 5)        ElseIf StrComp(Mid$(HTMLDecode, i, 4), "<", vbTextCompare) = 0 Then            HTMLDecode = Left$(HTMLDecode, i - 1) & "<" & Mid$(HTMLDecode, _                i + 4)        ElseIf StrComp(Mid$(HTMLDecode, i, 4), ">", vbTextCompare) = 0 Then            HTMLDecode = Left$(HTMLDecode, i - 1) & ">" & Mid$(HTMLDecode, _                i + 4)        End If    LoopEnd Function

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.