This article mainly introduces the code and ideas for getting Yahoo! exchange rates using vbs. For more information, see use vbs to get Yahoo! exchange rates.
Function bytes2bstr (vin) 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 = strreturnEnd FunctionFunction GetURL (url) Set Retrieval = CreateObject ("Microso Ft. XMLHTTP ") With Retrieval. open "GET", url, False. send GetURL = bytes2bstr (. responsebody) if len (. responsebody) <2 then strContent = "remote communication fault! "Call LogToFile (strContent, 1) response. end if End With Set Retrieval = NothingEnd function' ======== the above are custom functions ======== s1 = INPUTBOX ("original currency code: "," Enter the original currency code "," USD ") s2 = INPUTBOX (" target currency code: "," Enter the target currency code "," CNY ") s = s1 & s2url =" http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s= "& S &" = x "if s1 <>" "and s2 <>" "Then huilv = GetURL (url) MsgBox huilvEnd if
For more articles about using vbs to get Yahoo!