Weather Adviser

12 points


Setting up the Form

Which season is it?
To set up the "Which season is it?" section in the upper-left of the form, add a Label, a ListBox and a PictureBox to the form. Rename the ListBox 'lstSeasons' and the PictureBox 'picSeasons'.
To add the seasons to the ListBox, select the ListBox and click on the small Play icon on the upper edge of the control. Choose 'Edit Items' and enter the seasons.
You will display images of the seasons in the PictureBox. You will probably want your images to resize to fit in the PictureBox. To get this to happen: PictureBox > Behavior > SizeMode > StretchImage.

To enable your project to "see" your images, store the images in the bin / Debug folder, inside your project folder.

What is the temperature?
Add to the form a Label and sets its Text property to 'What is today's temperature?' or something similar.
Add a TextBox (and rename it 'txtTemp').
Add a Button and set its Text to 'Click to Get Advice' or something similar.
Add a Label and set its Text property to 'My Advice:' or something similar.
Add a Label (and rename it 'lblAdvice') to display the programmer's advice.

Add 2 RadioButtons to the form, 1 for Weekend and 1 for Weekday.

Here is what my program looks like when it is running:


Writing the Code

Which season is it?
You display an appropriate image, in the Picture Box, for the season that the user clicks on in the Listbox. To get started writing this code, in the design view double-click on the ListBox. The heading in the code view looks like this:
Private Sub lstSeasons_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstSeasons.SelectedIndexChanged
The 'selectedItem' property of the Listbox records which item the user clicked on. For example, if a user clicks on "Winter" then 'lstSeasons.selectedItem' will be set equal to "Winter". You can use 'lstSeasons.selectedItem' to set up an IF - ELSEIF statement that displays the correct image in the PictureBox. Here is the code that displays a given image in 'picSeasons':
picSeasons.Image = Image.FromFile("fall.jpg").

What is the temperature?
Use the CDbl() command to assign the number in 'txtTemp.Text' to a double:
Dim Temp As Double
Temp = CDbl(txtTemp.Text)

You can use nested IF statements to respond to what the user has said. The outer IF statements can deal with the temperature. You can have 4 categories: temperatures above 75, above 55, above 35 and below 35. Set up an IF - ELSEIF structure for the temperature.

The inner IF statements can deal with whether the user selected 'Weekend' or 'Weekday'. You can check that by seeing whether the '.checked' property of one of the RadioButtons is True.

Inside each inner IF, give the user advice by changing the Text property of 'lblAdvice'.



You can download my version of this program here (, to get an idea of what your program will do when it is complete.