VB URL 编码与解码,VB URL 加密与解密,VB URL 编码,VB URL 加密,VB URL 解码,VB URL 解密,VB UrlEncoding,VB URLDecode。

VB URL 编码,VB URL 加密:

Public Function UrlEncoding(StrX As String) As String                           'URL编码
    On Error GoTo over
    Dim I, StrReturn As String, Thischr, Innercode
    StrReturn = ""
    For I = 1 To Len(StrX)
        Thischr = Mid(StrX, I, 1)
        If Abs(Asc(Thischr)) < &HFF Then
            If Thischr = " " Then
                StrReturn = StrReturn & "+"
            ElseIf InStr("!""#$%&'()*+,/:;<=>?@[\]^`{|}~%", Thischr) > 0 Then
                StrReturn = StrReturn & "%" & Hex(Asc(Thischr))
            Else
                StrReturn = StrReturn & Thischr
            End If
        Else
            Innercode = Asc(Thischr)
            If Innercode < 0 Then Innercode = Innercode + &H10000
            StrReturn = StrReturn & "%" & Hex((Innercode And &HFF00) \ &HFF) & "%" & Hex(Innercode And &HFF)
        End If
    Next
    UrlEncoding = StrReturn
    Exit Function
over:
    UrlEncoding = ""
End Function

VB URL 解码,VB URL 解密:

Public Function URLDecode(ByRef strURL As String) As String                     'URL解码
    Dim I As Long
    If InStr(strURL, "%") = 0 Then URLDecode = strURL: Exit Function
    For I = 1 To Len(strURL)
        If Mid(strURL, I, 1) = "%" Then
            If Val("&H" & Mid(strURL, I + 1, 2)) > 127 Then
                URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, I + 1, 2) & Mid(strURL, I + 4, 2)))
                I = I + 5
            Else
                URLDecode = URLDecode & Chr(Val("&H" & Mid(strURL, I + 1, 2)))
                I = I + 2
            End If
        Else
            URLDecode = URLDecode & Mid(strURL, I, 1)
        End If
    Next
End Function