Function bytes2BSTR(vIn) 
	dim i 
	strReturn = "" 
	For i = 1 To LenB(vIn) 
		ThisCharCode = AscB(MidB(vIn,i,1)) 
		If ThisCharCode < &H80 Then 
			strReturn = strReturn & Chr(ThisCharCode) 
		Else 
			NextCharCode = AscB(MidB(vIn,i+1,1)) 
			strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) 
			i = i + 1 
		End If 
	Next 
	bytes2BSTR = strReturn 
End Function
Function str2asc(strstr) 
	str2asc = hex(asc(strstr)) 
End Function 
Function asc2str(ascasc) 
	on error resume next
		asc2str = chr(ascasc) 
	if err.Number <>0 then
		msgbox(ascasc)
	end if
End Function
function urlencode(vstrin) 
    dim i,strreturn,strSpecial 
    strSpecial = " <>""#%{}|^~[]`'&?+" 
    strreturn = "" 
    for i = 1 to len(vstrin) 
        thischr = mid(vstrin,i,1) 
        if abs(asc(thischr)) < &hff then 
            if instr(strSpecial,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 
            end if 
            hight8 = innercode \ 256 '(innercode  and &hff00)'   mod &hff
            low8 = innercode and &hff 
            strreturn = strreturn & "%" & hex(hight8) &  "%" & hex(low8) 
        end if 
    next 
    urlencode = strreturn 
end function 
