Through VB: Get Weather Information Using Web Service

21 Feb

Dim Req As New XMLHTTP
Dim Resp As New DOMDocument
Dim Weather As IXMLDOMNode
Dim CurrentWeather As IXMLDOMNode

Req.Open “GET”, “http://api.worldweatheronline.com/free/v1/weather.ashx?q=Karachi&format=xml&num_of_days=1&key=enter_you_own_key_by-registering”, False
Req.Send
Resp.loadXML (Req.responseText)

For Each CurrentWeather In Resp.getElementsByTagName(“current_condition”)
Me.LabelTemp.Caption = ” ” & CurrentWeather.SelectNodes(“temp_C”)(0).Text
Me.LabelTemp1.Caption = ” ” & CurrentWeather.SelectNodes(“humidity”)(0).Text
Me.LabelTemp2.Caption = ” ” & CurrentWeather.SelectNodes(“windspeedKmph”)(0).Text
Me.LabelTemp4.Caption = ” ” & CurrentWeather.SelectNodes(“winddir16Point”)(0).Text
Me.LabelTemp3.Caption = ” ” & CurrentWeather.SelectNodes(“pressure”)(0).Text

Next

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: