Week 14 AssignmentProfessor John J. Couture - Email: FALL11@JCouture.net
(Pending) Ref# A186-14
Week of 11/28/2011
The purpose of this assignment is to demonstrate the use of the webBrowser control and merging it
with skills we have learned this semester like writing to a text file and extracting data from an
XML file. Please note that the events below are purposely separated so
that it is easier to grade. In a production program, a programmer would typically combine some
events under a single button.
- Using the form below as your guide, create the form. Add the listbox, buttons and labels
||Clear the Database
||Download Winds Aloft / Save to Disk
||Update DB with Winds Aloft Data
||Update DB Station Names
||Clear and Load ComboBox from DB
||Load with logo from NWS site
||(inside status strip)
||Load with favicon.ico from NWS
- Add a StatusStrip control to your form.
- Using the dropdown box on the control, select "Status Label".
- Rename the status label to "statusMsg"
- Below, after each operation there is a "Status Message=". What that means is I want you
to update this status box using a method called Status(strMsg)
- Add a WebBrowser control to your form. You can leave the name as WebBrowser1.
The browser control is just used in the background so you will want to detach it from the parent
container (see tutorial above) and during run make it invisible.
- Set the form icon to the favicon.ico from the NWS site (probably easiest to download the icon
and save it locally)
- Set the initial picture in the picWeather control to the NWS logo. I downloaded mine from
Wikipedia (search Weather Service Logo) and set the picturebox control to 150 x 150.
Clear the Database
- Clear the combobox.
- Delete all the records in the database
- Status Message = "Database Has Been Cleared"
- Download Winds Aloft / Save to Disk (and the Document Complete event)
- Using your webbrowser control, download the winds aloft for the Continental United States
(link is above)
- Get the data from between the PRE tags in the web page (see Downloading ... Internet Tutorial
above). Lately we have been having trouble with the NWS data being in there twice. In
class we figured out a clever way to eliminate the second set using a DO WHILE loop and checking
the length of the line. See if you can do the same.
- Extract the "Data Based On ..." line from the file and display it in lblDate.
- Save the data to a file called FBIN.txt.
- Status Message = "Winds Aloft Data saved to file"
- Update DB with Winds Aloft Data
- For each station in the FBIN.txt file, add a record to the database using the stationID as the
key. Save the entire station weather record to the "windsaloft" field in the database.
- Status Message = "Database Updated - Winds Aloft"
- Update DB Station Names (Updated)
- For each record in the database, create an XML url to look up the surface weather
(see Assignment 11)
Download the surface weather and extract the station name, latitude and longitude. Update
those fields in the database. If a
station cannot be found, add a try/catch so your program does not bomb. Put "not found" in
the station name.
- Note: You will need to use two db objects (i.e. dbRead and dbWrite). One will be used to go
down through the database and the other will be used to update fields in the database.
- Note: This event will take a long time so you might want to add some code in there so that it
only updates about 20 records. There have been times when the Internet was so slow that it
took over a half hour to update the 150+ records.
- Note: Remember, your PROGRAM is supposed to do the update to the database (i.e. update the
station name, etc). You are not supposed to do the data entry into the database by hand.
Having said that, if you do, I will give you a zero for the assignment.
- Status Message = "DB Station Names Updated"
- Clear and Load the ComboBox from DB
- Clear the Combo box
- for each record in the database, load the stationID (and station name if you did the Update DB
Station Names code) into the combo box
- Status Message = "Combo Box Updated"
- Combo Box click event
- Ok, pay attention! This is an important event and constitutes a large
portion of your grade!
- Clear the list box
- Add the "Data Based On ..." to the listbox
- Determine the stationID from the ComboBox
- try (as some locations do not have surface weather, you may need to have a try/catch
- Download the XML surface weather
- Build the weather report (see sample below) and add it to the listbox
- Construct the Picture URL (see assignment #11), download it and replace the NWS logo.
- Lookup the station record in the database and extract the winds aloft field
- Create a NWSFB object using the winds aloft (station weather)
- for each of the nine altitudes, show the wind speed, direction and temperature and add it to
the listbox (see below)
- Status Message = "List Box Updated"
- Status method
- Create a method called status that accepts a string parameter
- Update the statusMsg object with the string parameter
- Refresh the screen (this is done by adding a single line as follows:
- NWSFB class
- Make sure the NWSFB class has all of the exceptions in it from assignment #6 and #9.
- Add XML comments to all your code files.
- Add regular comments WITHIN your subroutines and functions which explain what your code is
- Create an HTML file from your XML comments using your Transform program.
What to Upload (6 files)
- (50 points) Form1.vb - make a copy of the code file and rename it to
- (5 points) Form1.Designer.vb - make a copy of the file and rename it to
- (10 points) The XML documentation file named A186-14.htm
- (5 points) dbUpdt.vb - make a copy of the file and rename it to
- (5 points) NWSFB.vb - make a copy of the file and rename it to
- (25 points) Weather.mdb
Sample Listbox Contents:
DATA BASED ON 021800Z
location: San Diego/Lindbergh, CA
observation_time: Last Updated on Dec 2 2009, 2:51 pm PST
weather: Mostly Cloudy
temperature_string: 60.0 F (15.6 C)
wind_string: West at 11.5 MPH (10 KT)
pressure_string: 1013.6 mb
dewpoint_string: 46.0 F (7.8 C)
windchill_string: 58 F (14 C)
Altitude Weather at 03,000 feet: Dir Calm Speed Calm Temperature N/A
Altitude Weather at 06,000 feet: Dir 320 Speed 6 Temperature +09
Altitude Weather at 09,000 feet: Dir 320 Speed 10 Temperature +05
Altitude Weather at 12,000 feet: Dir 320 Speed 12 Temperature -03
Altitude Weather at 18,000 feet: Dir 310 Speed 19 Temperature -18
Altitude Weather at 24,000 feet: Dir 290 Speed 20 Temperature -31
Altitude Weather at 30,000 feet: Dir 310 Speed 16 Temperature -47
Altitude Weather at 36,000 feet: Dir 310 Speed 18 Temperature -55
Altitude Weather at 39,000 feet: Dir 290 Speed 58 Temperature -55