|
楼主 |
发表于 2012-2-22 12:52
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
换一方式的城市天气预报
本帖最后由 chuhaiou 于 2012-2-22 13:18 编辑
Sub 天气预报()
'//第二天合肥天气预报
'Application.Cursor = xlWait
Dim InputStr As String
Dim sc As New MSSOAPLib.SoapClient
InputStr = "合肥"
sc.MSSoapInit "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?WSDL"
' Dim re() As String
re = sc.getSupportCity("")
For i = 0 To UBound(re)
TempStr = "*" & InputStr & "*"
If re(i) Like TempStr Then
TempStr = Replace(re(i), ")", "")
TempStr = Right(TempStr, 5)
Exit For
End If
Next i
re = sc.getWeatherbyCityName(TempStr)
r = UBound(re)
MsgBox re(13) & Chr(13) & re(12) & Chr(13) & re(14), , "合肥天气预报"
End Sub
注意要引用Microsoft Soap Type Library 控件
只能显示城市,但不能显示县级的天气预报。怎样解决这一难题?请高手解决。谢谢!
|
|