30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 21 ASP .<strong>NET</strong> and Web Services 1079<br />

67 cityLabels.Add(32, label32)<br />

68 cityLabels.Add(33, label33)<br />

69 cityLabels.Add(34, label34)<br />

70<br />

71 ' create Hashtable and populate with all weather<br />

72 ' conditions<br />

73 Dim weather As New Hashtable()<br />

74 weather.Add("SUNNY", "sunny")<br />

75 weather.Add("PTCLDY", "pcloudy")<br />

76 weather.Add("CLOUDY", "mcloudy")<br />

77 weather.Add("MOCLDY", "mcloudy")<br />

78 weather.Add("TSTRMS", "rain")<br />

79 weather.Add("RAIN", "rain")<br />

80 weather.Add("SNOW", "snow")<br />

81 weather.Add("VRYHOT", "vryhot")<br />

82 weather.Add("FAIR", "fair")<br />

83 weather.Add("RNSNOW", "rnsnow")<br />

84 weather.Add("SHWRS", "showers")<br />

85 weather.Add("WINDY", "windy")<br />

86 weather.Add("NOINFO", "noinfo")<br />

87 weather.Add("MISG", "noinfo")<br />

88 weather.Add("DRZL", "rain")<br />

89 weather.Add("HAZE", "noinfo")<br />

90 weather.Add("SMOKE", "mcloudy")<br />

91 weather.Add("FOG", "mcloudy")<br />

92<br />

93 Dim i As Integer<br />

94 Dim background As New Bitmap("images/back.jpg")<br />

95 Dim font As New Font("Courier New", 8, _<br />

96 FontStyle.Bold)<br />

97<br />

98 ' for every city<br />

99 For i = 0 To cities.Length - 1<br />

100<br />

101 ' use Hashtable <strong>to</strong> find the next Label<br />

102 Dim currentCity As Label = _<br />

103 CType(cityLabels(i + 1), Label)<br />

104<br />

105 ' set current Label's image <strong>to</strong> the image<br />

106 ' corresponding <strong>to</strong> its weather condition -<br />

107 ' find correct image name in Hashtable weather<br />

108 currentCity.Image = New Bitmap("images/" & _<br />

109 weather(descriptions(i).Trim()).ToString & ".jpg")<br />

110<br />

111 ' set background image, font and forecolor<br />

112 ' of Label<br />

113 currentCity.BackgroundImage = background<br />

114 currentCity.Font = font<br />

115 currentCity.ForeColor = Color.White<br />

116<br />

Fig. 21.22 Receiving temperature and weather data from a Web service (part 3 of 4).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!