下午好。
我有一个程序要求雅虎提供天气!天气有效。但是,我想要做的是重新加载请求信息的代码块。
它是广播电台的一部分 - 工作室时钟,因此使用计划任务关闭&然后重新打开应用程序不是跑步者。
只有在加载.exe文件时才会请求信息一次。
我怎么用计时器呢?每15分钟一次都会很好。
以下是我所获得的代码 - 顺便说一句,不是我自己的代码,在网上找到了!
Sub GetWeatherReport(ByVal locationId As Integer)
Me.Text = strLocations(locationId)
Dim doc As New XPathDocument("http://weather.yahooapis.com/forecastrss?w=" & strLocationID(locationId) & "&u=c")
Dim nav As XPathNavigator = doc.CreateNavigator()
Dim ns As New XmlNamespaceManager(nav.NameTable)
ns.AddNamespace("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0")
Dim nodes As XPathNodeIterator = nav.[Select]("/rss/channel/item/yweather:condition", ns)
While (nodes.MoveNext())
Dim node As XPathNavigator = nodes.Current
lblTemp.Text = node.GetAttribute("temp", ns.DefaultNamespace).ToString() & "°C " + node.GetAttribute("text", ns.DefaultNamespace).ToString()
)
weatherImage.ImageLocation = "http://l.yimg.com/a/i/us/we/52/" & node.GetAttribute("code", ns.DefaultNamespace).ToString() & ".gif"
End While
谢谢!