Get Yahoo exchange rate using VBS
Function Bytes2bstr (vin) Strreturn = "" For i = 1 to LenB (vin) Thischarcode = ASCB (MidB (vin,i,1)) if Thischar Code < &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 I
F Next bytes2bstr = Strreturn End Function function GetURL (URL) Set retrieval = CreateObject ("Microsoft.XMLHTTP") With retrieval. Open ' get ', url, False. Send GetURL = Bytes2bstr (. responsebody) If Len (. responsebody) <2 then = "Remote communication failure!" "Call Logtofile (strcontent,1) Response.End End If End with Set retrieval = no end Function ' = = = = above is the custom function ======== S1 = INPUTBOX ("Original currency Code:", "Please enter the original currency code", "USD") s2 = INPUTBOX ("Destination Currency code:", "Please enter the destination currency code", "CNY") s = S1&s2 u RL = "http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=" &s& "=x" If S1<> ""and s2<> "" Then huilv = GetURL (URL) MsgBox Huilv End If