Now what happens with Break On Exceptions off, I get a message after I click the message box that the application quit unexpectedly, so it still closes down the app even with the error handling. So I don’t know what to do about that.
Below is the entire section of code.
[code]Sub GetWeather()
//Makes sure computer is connected with the Internet to get Weather.
if System.Network.IsConnected then
//MsgBox “you’re online!”
else
Exit
end if
// The WOEDI is the Yahoo weather location ID.
// You can get this by visiting http://weather.yahoo.com
// and entering a ZIP code.
// The WOEID appears in the resulting URL as the numbers at the end:
// http://weather.yahoo.com/united-states/maine/south-portland-12759449/
Dim url As String = “http://weather.yahooapis.com/forecastrss?w=” + txtWOEID.Text
Dim socket As New HttpSocket
Dim weatherInfo As String
weatherInfo = socket.Get(url, 5)
weatherInfo = DefineEncoding(weatherInfo, Encodings.UTF8)
WeatherInfoArea.Text = weatherInfo
// This returns an RSS feed, which is technially XML.
// So the XML can be loaded and parsed to get the weather information.
Dim weatherXml As New XmlDocument
Try
weatherXml.LoadXml(weatherInfo)
Catch e As XmlException
Exit
MsgBox("XML error: " + e.Message)
End Try
// Extract the current conditions from the XML
Dim itemNodes As XmlNodeList
itemNodes = weatherXml.Xql(“//item”)
Dim itemNode As XmlNode
For i As Integer = 0 To itemNodes.Length-1
itemNode = itemNodes.Item(i)
Dim child As XmlNode
For c As Integer = 0 To itemNode.ChildCount-1
child = itemNode.Child(c)
Select Case child.Name
Case "title"
txtTitle.Text = child.FirstChild.Value
Case "yweather:condition"
txtConditions.Text = child.GetAttribute("text")
txtWDate.Text = child.GetAttribute("date")
txtTemp.Text = child.GetAttribute("temp")
End Select
Next
Next
CallChannel[/code]
So if I do this it may prevent the error?
[code] weatherInfo = socket.Get(url, 5)
weatherInfo = DefineEncoding(weatherInfo, Encodings.UTF8)'=
If weatherInfo < > “” Then
WeatherInfoArea.Text = weatherInfo
// The rest of the code below.
End If[/code]