Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOPMOST = -1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Public Function UrlEncodeString(ByVal str As String) As String
Dim pos As Long ' current loc in src
Dim last As Long ' last loc in string
Dim ch As String ' current char
Dim cc As Integer ' char code
Dim hstr As String ' hex string
Dim out As String ' output string
Dim cSpace As Integer ' code for space
Dim cSquig As Integer ' code for squiggle
Dim cAmp As Integer ' code for amp
Dim cPlus As Integer ' code for plus
Dim cPct As Integer ' code for percent
Dim cEq As Integer ' code for equals
cSpace = Asc(" ")
cSquig = Asc("~")
cAmp = Asc("&")
cPlus = Asc("+")
cPct = Asc("%")
cEq = Asc("=")
last = Len(str)
pos = 1
While pos <= last
ch = Mid$(str, pos, 1)
cc = Asc(ch)
If cc = cSpace Then
out = out & "+"
ElseIf (cc > cSpace And cc <= cSquig _
And cc <> cAmp And cc <> cPlus _
And cc <> cPct And cc <> cEq) Then
out = out & ch
Else
' convert to hex
hstr = Hex$(cc)
hstr = Right$(hstr, 2) ' make sure it's only one byte
If Len(hstr) = 0 Then
hstr = "00"
ElseIf Len(hstr) = 1 Then
hstr = "0" & hstr
End If
out = out & "%" & hstr
End If
pos = pos + 1
Wend
UrlEncodeString = out
End Function
Public Function UrlDecodeString(ByVal inp As String) As String
Dim out As String
' change all pluses (+) to spaces ( ),
' and change all hex strings (%xx) to actual chars