ClassLibrary.vb
Public Class ClassLibrary
Public
Class DailyData
Private _strCondition As String = “”
Private _intHigh As Integer = 0
Private _intLow As Integer = 0
Private _strDay_of_Week As String = “”
Public Property Condition () As String
Get
Return _strCondition
End Get
Set (ByVal value As String)
_strCondition = value < br />
End Set
End Property
Public Property High () As Integer
Get
Return _intHigh < br />
End Get
Set (ByVal value As Integer)
_intHigh = value
End Set
End Property
Public Property Low () As Integer
Get
Return _intLow
End Get
Set (ByVal value As Integer)
_intLow = value
End Set
End Property
Public Property Day_of_Week () As String
Get
Return _strDay_of_Week
End Get
Set (ByVal value As String)
_strDay_of_Week = value
< br /> End Set
End Property
End
Class
End Class The
=========== ===========
WeatherBlock.vb
_
Partial Class WeatherBlock
Inherits
System.Windows.Forms.UserControl
serControl overrides dispose to clean up the component
list.
_
Protected
Overrides Sub Dispose (ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose ()
End If
Finally
MyBase.
, the Dispose (the disposing) End Try
End Sub
he Required
by the Windows Forms Designer
Private
components As System.ComponentModel.IContainer
OTE:
The following procedure is required by the Windows Form
Designer
It can be
modified using the Windows Form Designer.
o not
modify it using the code editor.
_
Private Sub
InitializeComponent ()
Me.Panel1 = New System.Windows.Forms.Panel
Me.LLo = New System.Windows . Forms.Label
Me.LHi = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.LDayofWeek = New System.Windows . Forms.Label
Me.Panel1.SuspendLayout ()
CType (Me.PictureBox1,
System.ComponentModel.ISupportInitialize). BeginInit ()
Me.SuspendLayout ()
lt;br />
Panel1
lt;br />
Me.Panel1. BackColor = System.Drawing.Color.Azure
Me.Panel1.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel1.Controls. Add (Me.LDayofWeek)
Me.Panel1.Controls.Add (Me.LLo)
Me.Panel1.Controls.Add (Me.LHi)
Me.Panel1.Controls.Add (Me.Label2)
Me.Panel1.Controls.Add (Me.Label1)
Me.Panel1.Controls. Add (Me.PictureBox1)
Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Panel1.Location = New System.Drawing.Point ( 0, 0)
Me.Panel1.Name = “Panel1″
Me.Panel1.Size = New System.Drawing.Size (64, 125)
Me.Panel1.TabIndex = 0
lt;br />
LLo
lt;br />
Me.LLo . Font = New System.Drawing.Font (“Tahoma”, 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.LLo.Location = New System.Drawing.Point (34, 94)
Me.LLo.Name = “LLo”
Me. LLo.Size = New System.Drawing.Size (26, 18)
Me.LLo.TabIndex = 4
Me.LLo.Text = “10″
Me.LLo.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
lt;br />
LHi
lt;br />
Me.LHi.Font = New System.Drawing.Font (“Tahoma”, 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType ( 0, Byte))
Me.LHi.Location = New System.Drawing.Point (34, 71)
Me.LHi.Name = “LHi”
Me.LHi.Size = New System.Drawing.Size (26, 18)
Me.LHi.TabIndex = 3
Me.LHi.Text = “40″
Me.LHi.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
lt;br />
Label2
lt;br />
Me.Label2.Font = New System.Drawing.Font (“Tahoma”, 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point ,
CType (0, Byte))
Me.Label2.Location = New System.Drawing.Point (8, 93)
Me.Label2.Name = “Label2″
Me.Label2.Size = New System.Drawing.Size (27, 18)
Me.Label2.TabIndex = 2
Me.Label2.Text = “Lo:”
Me.Label2.TextAlign =
System.Drawing.ContentAlignment.MiddleRight
lt;br />
abel1
Me.Label1.Font = New System.Drawing.Font (“Tahoma”, 8.25!,
System.Drawing . FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.Label1.Location = New System.Drawing.Point (8, 72) < br />
Me.Label1.Name = “Label1″
Me.Label1.Size = New System.Drawing.Size (27, 17)
Me . Label1.TabIndex = 1
Me.Label1.Text = “Hi:”
Me.Label1.TextAlign =
System.Drawing.ContentAlignment.MiddleRight < br />
lt;br />
PictureBox1
lt;br />
Me.PictureBox1.Location = New System.Drawing.Point (12, 26)
Me.PictureBox1.Name = “PictureBox1″
Me.PictureBox1.Size = New System.Drawing.Size (40, 40)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
lt;br />
LDayofWeek
lt;br />
Me.LDayofWeek.Font = New System.Drawing.Font (“Tahoma”, 9.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.LDayofWeek.Location = New System.Drawing.Point (4, 7)
Me.LDayofWeek.Name = “LDayofWeek”
Me.LDayofWeek.Size = New System.Drawing.Size (54, 13)
Me.LDayofWeek.TabIndex = 5
Me.LDayofWeek.Text = “Wed”
Me.LDayofWeek.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
lt;br />
eatherBlock
Me.AutoScaleDimensions = New System.Drawing.SizeF (6.0!,
13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Controls.Add (Me.Panel1)
Me.Name = “WeatherBlock”
Me.Size = New System.Drawing.Size (64, 125)
Me.Panel1.ResumeLayout (False)
CType (Me.PictureBox1, < br /> System.ComponentModel.ISupportInitialize). EndInit ()
Me.ResumeLayout (False)
End
Sub
Friend
WithEvents Panel1 As System.Windows.Forms.Panel
Friend
WithEvents Label2 As System.Windows.Forms.Label
Friend
WithEvents Label1 As System . Windows.Forms.Label
Friend
WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend
WithEvents LLo As System.Windows.Forms . Label
Friend
WithEvents LHi As System.Windows.Forms.Label
Friend
WithEvents LDayofWeek As System.Windows.Forms.Label
End Class
escriptions:
Note: the gif
, we e used has a size of 40 x 40
lt;br />
Author / Date: 2010-07-14, Edchy Tsoi
Public Class WeatherBlock
Private
_strCondition As String = “”
< br /> Private
_strHigh As String = “”
Private
_strLow As String = “”
Private
_strDay_of_Week As String = “”
Private
_objImage As Drawing.Image = Nothing
# Region “Property”
Public
Property Condition () As String
Get
Return _strCondition
End Get
Set (ByVal value As String)
_strCondition = of value
End Set
End
Property
Public
Property High () As String
Get < br />
Return _strHigh
End Get
Set (ByVal value As String)
_strHigh = value
< br /> End Set
End
Public
Property Low, () As String, Property
Get
Return _strLow
End Get
Set (ByVal value As String)
_strLow = value
End Set < br />
End
Property
Public
Property Day_of_Week () As String
Get
Return _strDay_of_Week
End Get
Set (ByVal value As String)
_strDay_of_Week = value
End Set
End
Property
Public
Property Image () As Image
Get
Return _objImage
End Get
Set (ByVal value As Image)
_objImage = value
End Set
End
Property
# End Region
# Region “Public”
Public
Sub RefreshData ()
Me.LHi.Text = F_to_C (Me.High)
Me.LLo.Text = F_to_C (Me.Low)
Me.PictureBox1.Image = Me.Image
Me.LDayofWeek.Text = Me.Day_of_Week
End
Sub
Public
Sub Reset ()
lear up all the data
Me . PictureBox1.Image = Nothing
Me.LHi.Text = “”
Me.LLo.Text = “”
Me.LDayofWeek. Text = “”
End Sub
# End Region
# Region “private”
Private
Function F_to_C (ByVal strValue As String) As String < br />
onvert Fahrenheit to Celsius
ref: http://en.wikipedia.org/wiki/Temperature_conversion
lt;br />
C = (F-32) x (5/9)
lt;br />
NOTE: Some time the the input string is empty ….
Try
If Not String.IsNullOrEmpty (strValue) Then
Return CInt ((CInt (strValue) – 32) * 5/9). ToString
Else
Return “”
End If
Catch objE As Exception
gnore any error
Return “”
End Try
, End
Function # End Region
End Class
====== ====================
FrmWeather.vb
_
Partial Class FrmWeather
Inherits
System.Windows.Forms.Form
orm
overrides dispose to clean up the component list.
_
Protected
Overrides Sub Dispose (ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose ()
End If
Finally
< br /> MyBase.Dispose (the disposing)
End Try
End Sub
he Required
by the Windows Form Designer
Private components As
System.ComponentModel.IContainer
OTE:
The following procedure is required by the Windows Forms
Designer
It can be
modified using the Windows Form Designer.
o not
modify it using the code editor.
_
Private Sub
InitializeComponent ()
Me.components = New System.ComponentModel.Container
Dim resources As System. ComponentModel.ComponentResourceManager =
New
System.ComponentModel.ComponentResourceManager (GetType (FrmWeather))
Me.BtnGetWeather = New System.Windows.Forms.Button
Me. Panel1 = New System.Windows.Forms.Panel
Me.Lhumidity = New System.Windows.Forms.Label
Me.Ltemp = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me. PictureBoxNow = New System.Windows.Forms.PictureBox
Me.LCity = New System.Windows.Forms.Label
Me.ImageList1 = New
System.Windows . Forms.ImageList (Me.components)
Me.ComboCountry = New System.Windows.Forms.ComboBox
Me.ComboCity = New System.Windows.Forms.ComboBox < br />
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Panel2 = New System.Windows.Forms.Panel
Me.WeatherBlock4 = New GoogleWeather.WeatherBlock
Me.WeatherBlock3 = New GoogleWeather.WeatherBlock
Me . WeatherBlock2 = New GoogleWeather.WeatherBlock
Me.WeatherBlock1 = New GoogleWeather.WeatherBlock
Me.Panel1.SuspendLayout ()
CType (Me. PictureBoxNow,
System.ComponentModel.ISupportInitialize). BeginInit ()
Me.Panel2.SuspendLayout ()
Me.SuspendLayout ()
lt;br />
BtnGetWeather
lt;br />
Me.BtnGetWeather.FlatStyle =
System.Windows.Forms.FlatStyle.Flat < br />
Me.BtnGetWeather.Location = New System.Drawing.Point (57, 58)
Me.BtnGetWeather.Name = “BtnGetWeather”
Me . BtnGetWeather.Size = New System.Drawing.Size (190, 23)
Me.BtnGetWeather.TabIndex = 1
Me.BtnGetWeather.Text = “Get Weather” < br />
Me.BtnGetWeather.UseVisualStyleBackColor = True
lt;br />
Panel1
lt;br />
Me.Panel1.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel1.Controls.Add (Me.Lhumidity)
Me.Panel1 . Controls.Add (Me.Ltemp)
Me.Panel1.Controls.Add (Me.Label2)
Me.Panel1.Controls.Add (Me.Label1) < br />
Me.Panel1.Controls.Add (Me.PictureBoxNow)
Me.Panel1.Controls.Add (Me.LCity)
Me.Panel1 . Location = New System.Drawing.Point (5, 98)
Me.Panel1.Name = “Panel1″
Me.Panel1.Size = New System.Drawing. Size (253, 79)
Me.Panel1.TabIndex = 8
lt;br />
Lhumidity
lt; br />
Me.Lhumidity.Font = New System.Drawing.Font (“Tahoma”, 9.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.Lhumidity.Location = New System.Drawing.Point (182, 55)
Me.Lhumidity.Name = “Lhumidity”
Me.Lhumidity.Size = New System.Drawing.Size (53, 16)
Me.Lhumidity.TabIndex = 5
Me. Lhumidity.Text = “10″
Me.Lhumidity.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft
lt;br />
Ltemp
lt;br />
Me.Ltemp.Font = New System.Drawing.Font (“Tahoma”, 9.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.Ltemp.Location = New System.Drawing.Point (182, 36)
Me.Ltemp.Name = “Ltemp”
Me.Ltemp.Size = New System.Drawing.Size (53, 16)
Me.Ltemp.TabIndex = 4
Me.Ltemp.Text = “10″
Me.Ltemp.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft
lt;br />
Label2
lt;br />
Me.Label2.Font = New System.Drawing.Font (“Tahoma”, 9.0!, < br /> System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.Label2.Location = New System.Drawing.Point (87, 54)
Me.Label2.Name = “Label2″
Me.Label2.Size = New System.Drawing.Size (92, 16)
Me.Label2.TabIndex = 3
Me.Label2.Text = “Humidity:”
Me.Label2.TextAlign =
System. Drawing.ContentAlignment.MiddleRight
lt;br />
Label1
lt;br />
Me.Label1.Font = New System. Drawing.Font (“Tahoma”, 9.0!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.Label1.Location = New System.Drawing.Point (87, 35)
Me.Label1.Name = “Label1″
Me.Label1.Size = New System . Drawing.Size (92, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = “Temperture:”
Me.Label1.TextAlign =
System.Drawing.ContentAlignment.MiddleRight
lt;br />
PictureBoxNow
lt;br /> < br /> Me.PictureBoxNow.Location = New System.Drawing.Point (6,
Me.PictureBoxNow.Name = “PictureBoxNow”
Me.PictureBoxNow.Size = New System.Drawing.Size (60, 60)
Me.PictureBoxNow.SizeMode =
System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBoxNow . TabIndex = 1
Me.PictureBoxNow.TabStop = False
lt;br />
LCity
lt;br / >
Me.LCity.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.LCity.Font = New System.Drawing.Font (“Tahoma”, 9.75 !,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType (0, Byte))
Me.LCity.Location = New System. Drawing.Point (73, 9)
Me.LCity.Name = “LCity”
Me.LCity.Size = New System.Drawing.Size (172, 23)
Me.LCity.TabIndex = 0
Me.LCity.Text = “city”
Me.LCity.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
lt;br />
ImageList1
lt;br />
Me.ImageList1.ImageStream = < br /> CType (resources.GetObject (“ImageList1.ImageStream”),
System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor =
System.Drawing. Color.Transparent
Me.ImageList1.Images.SetKeyName (0, “sunny.gif”)
Me.ImageList1.Images.SetKeyName (1, “chance_of_rain.gif” )
Me.ImageList1.Images.SetKeyName (2, “partly_cloudy.gif”)
Me.ImageList1.Images.SetKeyName (3, “rain.gif”) < br />
Me.ImageList1.Images.SetKeyName (4, “mostly_sunny.gif”)
Me.ImageList1.Images.SetKeyName (5, “chance_of_storm.gif”)
Me.ImageList1.Images.SetKeyName (6, “cloudy.gif”)
Me.ImageList1.Images.SetKeyName (7, “mostly_cloudy.gif”)
< br /> Me.ImageList1.Images.SetKeyName (8, “mist.gif”)
Me.ImageList1.Images.SetKeyName (9, “thunderstorm.gif”)
Me.ImageList1.Images.SetKeyName (10, “haze.gif”)
lt;br />
ComboCountry
lt;br /> < br /> Me.ComboCountry.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboCountry.FormattingEnabled = True
Me.ComboCountry.Location = New System.Drawing.Point (57, 7)
Me.ComboCountry.Name = “ComboCountry”
Me.ComboCountry.Size = New System.Drawing.Size ( 190, 21)
Me.ComboCountry.TabIndex = 6
lt;br />
ComboCity
lt;br / >
Me.ComboCity.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboCity.FormattingEnabled = True
Me.ComboCity . Location = New System.Drawing.Point (57, 32)
Me.ComboCity.Name = “ComboCity”
Me.ComboCity.Size = New System.Drawing. Size (190, 21)
Me.ComboCity.TabIndex = 7
lt;br />
Label3
lt; br />
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point (6, 10)
Me.Label3 . Name = “Label3″
Me.Label3.Size = New System.Drawing.Size (43, 13)
Me.Label3.TabIndex = 9
Me.Label3.Text = “Country”
lt;br />
Label4
lt;br />
Me . Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point (6, 36)
Me.Label4.Name = “Label4″
Me.Label4.Size = New System.Drawing.Size (24, 13)
Me.Label4.TabIndex = 10
Me.Label4. Text = “City”
lt;br />
Panel2
lt;br />
Me.Panel2.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel2.Controls.Add (Me.BtnGetWeather)
Me.Panel2.Controls.Add (Me.Label4)
Me.Panel2.Controls.Add (Me.ComboCountry)
Me.Panel2.Controls.Add (Me.Label3)
Me. Panel2.Controls.Add (Me.ComboCity)
Me.Panel2.Location = New System.Drawing.Point (5, 6)
Me.Panel2.Name = ” Panel2 “
Me.Panel2.Size = New System.Drawing.Size (253, 93)
Me.Panel2.TabIndex = 11
lt;br />
WeatherBlock4
lt;br />
Me.WeatherBlock4.Condition = “”
Me.WeatherBlock4.Day_of_Week = “”
Me.WeatherBlock4.High = “”
Me.WeatherBlock4.Image = Nothing
Me.WeatherBlock4.Location = New System. Drawing.Point (194,
176)
Me.WeatherBlock4.Low = “”
Me.WeatherBlock4.Name = “WeatherBlock4″
< br /> Me.WeatherBlock4.Size = New System.Drawing.Size (64, 126)
Me.WeatherBlock4.TabIndex = 7
lt;br />
eatherBlock3
Me.WeatherBlock3.Condition = “”
Me.WeatherBlock3.Day_of_Week = “”
< br /> Me.WeatherBlock3.High = “”
Me.WeatherBlock3.Image = Nothing
Me.WeatherBlock3.Location = New System.Drawing.Point (131, < br /> 176)
Me.WeatherBlock3.Low = “”
Me.WeatherBlock3.Name = “WeatherBlock3″
Me.WeatherBlock3. Size = New System.Drawing.Size (64, 126)
Me.WeatherBlock3.TabIndex = 6
lt;br />
WeatherBlock2
lt;br />
Me.WeatherBlock2.Condition = “”
Me.WeatherBlock2.Day_of_Week = “”
Me.WeatherBlock2. High = “”
Me.WeatherBlock2.Image = Nothing
Me.WeatherBlock2.Location = New System.Drawing.Point (68, 176)
Me.WeatherBlock2.Low = “”
Me.WeatherBlock2.Name = “WeatherBlock2″
Me.WeatherBlock2.Size = New System.Drawing.Size (64, 126)
Me.WeatherBlock2.TabIndex = 5
lt;br />
WeatherBlock1
lt;br /> < br /> Me.WeatherBlock1.Condition = “”
Me.WeatherBlock1.Day_of_Week = “”
Me.WeatherBlock1.High = “”
Me.WeatherBlock1.Image = Nothing
Me.WeatherBlock1.Location = New System.Drawing.Point (5, 176)
Me.WeatherBlock1.Low = “” < br />
Me.WeatherBlock1.Name = “WeatherBlock1″
Me.WeatherBlock1.Size = New System.Drawing.Size (64, 126)
Me . WeatherBlock1.TabIndex = 3
lt;br />
FrmWeather
lt;br />
Me.AutoScaleDimensions = New System.Drawing . SizeF (6.0!,
13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing. Color.Lavender
Me.ClientSize = New System.Drawing.Size (263, 306)
Me.Controls.Add (Me.Panel2)
Me.Controls.Add (Me.Panel1)
Me.Controls.Add (Me.WeatherBlock4)
Me.Controls.Add (Me.WeatherBlock3)
Me.Controls.Add (Me.WeatherBlock2)
Me.Controls.Add (Me.WeatherBlock1)
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Name = “FrmWeather”
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen < br />
Me.Text = “Weather”
Me.Panel1.ResumeLayout (False)
CType (Me.PictureBoxNow,
System. ComponentModel.ISupportInitialize). EndInit ()
Me.Panel2.ResumeLayout (False)
Me.Panel2.PerformLayout ()
Me.ResumeLayout (False)
End
Sub
Friend
WithEvents BtnGetWeather As System.Windows.Forms.Button
Friend
WithEvents WeatherBlock1 As GoogleWeather.WeatherBlock
Friend
WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend
WithEvents WeatherBlock4 As GoogleWeather.WeatherBlock
Friend
WithEvents WeatherBlock3 As GoogleWeather.WeatherBlock
Friend
WithEvents WeatherBlock2 As GoogleWeather.WeatherBlock
Friend
WithEvents Panel1 As System.Windows.Forms.Panel
Friend
WithEvents Label2 As System.Windows.Forms.Label
Friend
WithEvents Label1 As System.Windows . Forms.Label
Friend
WithEvents PictureBoxNow As System.Windows.Forms.PictureBox
Friend
WithEvents LCity As System.Windows.Forms.Label
Friend
WithEvents Lhumidity As System.Windows.Forms.Label
Friend
WithEvents Ltemp As System.Windows.Forms.Label
Friend
WithEvents ComboCountry As System.Windows.Forms.ComboBox
Friend
WithEvents ComboCity As System.Windows.Forms.ComboBox
friend
WithEvents Label3 of As System.Windows.Forms.Label
Friend
the WithEvents Label4 As System.Windows.Forms.Label
Friend
WithEvents Panel2 As System.Windows.Forms.Panel
End Class
Imports System.Net
Imports System.Xml
Public Class FrmWeather
Private
_bolSetupData As Boolean = False
Private
_strApplicationFolder As String =
IO.Path.GetDirectoryName (Application.ExecutablePath)
# Region ” Private “
Private
Function GetWeather (ByVal strCity As String, ByVal strCountryCode
As String) As XmlDocument
Dim objWebRequest As HttpWebRequest = Nothing
Dim objWebResponse As HttpWebResponse = Nothing
Dim objXML As XmlDocument = Nothing
Try
strCity = strCity.Replace (“”, ” “). Trim.ToLower
Dim strURL As String =” http://www.google.com/ig/api?weather = “
strCity “, ” strCountryCode < br />
objWebRequest = CType (WebRequest.Create (strURL),
HttpWebRequest)
objWebResponse = CType (objWebRequest.GetResponse (),
HttpWebResponse)
If objWebResponse.StatusCode = HttpStatusCode.OK Then
objXML = New XmlDocument ()
Try
objXML.Load (objWebResponse.GetResponseStream ())
Catch objE2 As Exception
he call may not success
objXML = Nothing
End Try
Else
MsgBox (“Weather Request Failed!”)
End If
If objXML IsNot Nothing Then
sing. OuterXml .. the text is not formatted
e.TXML.Text = objXML.OuterXml
save to file for debug only
If Not IO.Directory.Exists (_strApplicationFolder “\ Weather”)
Then
IO.Directory.CreateDirectory (_strApplicationFolder
“\ Weather”)
End If
objXML.Save (_strApplicationFolder “\ Weather” strCity
“. xml “)
End If
Return objXML
Catch objE As Exception
MsgBox (objE.ToString) < br />
Return Nothing
Finally
objWebResponse.Close ()
End Try
End
Function
Private
Function GetCity (ByVal strCountryCode As String) As XmlDocument
Dim objWebRequest As HttpWebRequest = Nothing
Dim objWebResponse As HttpWebResponse = Nothing
Dim objXML As XmlDocument = Nothing
Dim strURL As String = “http://www.google.com/ig/cities?output=xml