使用vbs获取雅虎汇率
使用vbs获取雅虎汇率
Functionbytes2bstr(vin)
strreturn=""
fori=1tolenb(vin)
thischarcode=ascb(midb(vin,i,1))
ifthischarcode<&h80then
strreturn=strreturn&chr(thischarcode)
else
nextcharcode=ascb(midb(vin,i+1,1))
strreturn=strreturn&chr(clng(thischarcode)*&h100+cint(nextcharcode))
i=i+1
endif
next
bytes2bstr=strreturn
EndFunction
FunctionGetURL(url)
SetRetrieval=CreateObject("Microsoft.XMLHTTP")
WithRetrieval
.Open"GET",url,False
.Send
GetURL=bytes2bstr(.responsebody)
iflen(.responsebody)<2then
strContent="远程通讯故障!"
CallLogToFile(strContent,1)
response.end
endif
EndWith
SetRetrieval=Nothing
EndFunction
'========以上为自定义函数========
s1=INPUTBOX("原始货币代码:","请输入原始货币代码","USD")
s2=INPUTBOX("目标货币代码:","请输入目标货币代码","CNY")
s=s1&s2
url="http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s="&s&"=x"
ifs1<>""ands2<>""Then
huilv=GetURL(url)
MsgBoxhuilv
Endif