HTMLDecodeEx – Decodes HTML encoded strings

HTMLDecodeEx – Decodes HTML encoded strings

' Decodes HTML encoding applied to the specified Text and returns the result' Optionally specify if we encoded a HREF link and the character' used for encoding - the default is the standard ampersand' i.e. Call MsgBox(HTMLDecodeEx("<Sample HTML Decoded Text>"' & ""))Public Function HTMLDecodeEx(ByVal Text As String, Optional ByVal vfHREFDecode _    As Boolean = False, Optional ByVal vstrAmpChar As String = "&") As String        Dim astrTokens() As String    Dim lngTotal As Long    Dim lngCount As Long    Dim strToken As String    Dim strCode As String    Dim lngPos As Long    Dim astrReturn() As String    Dim strReturn As String        strReturn = Text        If Trim$(strReturn) <> "" Then        ' tokenize the text        astrTokens = Split(Text, vstrAmpChar, -1, vbTextCompare)                    lngTotal = UBound(astrTokens)                ' create enough space for the return        ReDim astrReturn(lngTotal)                For lngCount = 0 To lngTotal            ' look for the end of the token            strToken = astrTokens(lngCount)            lngPos = InStr(1, strToken, ";", vbTextCompare)            If (lngPos = 0) Then                astrReturn(lngCount) = strToken            Else                strCode = Mid$(strToken, 1, lngPos)                Select Case strCode                    Case "nbsp;"                        astrReturn(lngCount) = " " & Mid$(strToken, lngPos + 1)                    Case "quot;"                        astrReturn(lngCount) = """" & Mid$(strToken, lngPos + 1)                    Case "amp;"                        astrReturn(lngCount) = vstrAmpChar & Mid$(strToken, _                            lngPos + 1)                    Case "lt;"                        astrReturn(lngCount) = "<" & Mid$(strToken, lngPos + 1)                    Case "gt;"                        astrReturn(lngCount) = ">" & Mid$(strToken, lngPos + 1)                    Case Else                        ' see if it's                        If Left$(strToken, 1) = "#" Then                            astrReturn(lngCount) = Chr$(Mid$(strToken, 2, _                                lngPos - 2)) & Mid$(strToken, lngPos + 1)                        Else                            astrReturn(lngCount) = strToken                        End If                End Select            End If        Next ' lngCount                Erase astrTokens                strReturn = Join(astrReturn, "")            Erase astrReturn    End If        HTMLDecodeEx = strReturn    End Function'###################################'#'# This tip has been brought to you by www.omnisolvonline.com,'# makers of a host of software development, energy and information '# management tools.'#'###################################

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular