7,762
社区成员
发帖
与我相关
我的任务
分享
Public Function URLEncode(ByVal strParameter As String) As String
Dim S As String
Dim i As Double
Dim intValue As Integer
Dim TmpData() As Byte
S = ""
TmpData = StrConv(strParameter, vbFromUnicode)
For i = 0 To UBound(TmpData)
intValue = TmpData(i)
If (intValue >= 48 And intValue <= 57) Or (intValue >= 65 And intValue <= 90) Or (intValue >= 97 And intValue <= 122) Then
S = S & Chr(intValue)
ElseIf intValue = 32 Then
S = S & "+"
Else
S = S & "%" & Hex(intValue)
End If
Next i
URLEncode = S
End Function