mbmailasgn08.htm; updated 4/15/2004

 

VB Mail Assignment 8

 

The VB Mail Order firm has hired you to create a project that displays the mailing distance between two cities.  The project will compute the cost of mailing a package as a function of the distance between cities.  The form for the project is shown here.

 

 

 

Requirements.

 

At Design Mode:

  • Store the distances in a two-dimensional table.  The distances are:

 

 

Boston

Chicago

Dallas

Las Vegas

Los Angeles

Miami

New Orleans

Toronto

Vancouver

Washington D.C.

Boston

0

1004

1753

2752

3017

1520

1507

609

3155

448

Chicago

1004

0

921

1780

2048

1397

919

515

2176

709

Dallas

1753

921

0

1230

1399

1343

517

1435

2234

1307

Las Vegas

2752

1780

1230

0

272

2570

1732

2251

1322

2420

Los Angeles

3017

2048

1399

272

0

2716

1858

2523

1278

2646

Miami

1520

1397

1343

2570

2716

0

860

1494

3447

1057

New Orleans

1507

919

517

1732

1858

860

0

1307

2734

1099

Toronto

609

515

1435

2251

2523

1494

1307

0

2820

571

Vancouver

3155

2176

2234

1322

1278

3447

2734

2820

0

2887

Washington D.C.

448

709

1307

2420

2646

1057

1099

571

2887

0

 

 

  • The charge for shipment is a function of the miles and is expressed using the table shown below.  Use a Select Case structure to compute the correct mileage charge. 

 

Miles

Charge

0

No charge

1 to 100

$0.075 / mile

101 to 800

$0.07 / mile

801 to 1500

$0.065 / mile

1501 and over

$0.06 / mile

 

Ø      Example #1:  a package is to be shipped from Toronto to Chicago, a total of 515 miles.  The cost is computed as follows:

o       First 100 miles @ 7.5 cents/mile = $7.50

o       Next 415 miles @ 7 cents/mile = $29.05

o       Total cost of shipment = $7.50 + $29.05 = $36.55

Ø      Example #2:  a package is to be shipped from Miami to Las Vegas, a total of 2570 miles.  The cost is computed as follows:

o       First 100 miles @ 7.5 cents/mile = $7.50

o       Next 700 miles @ 7 cents/mile = $49.00

o       Next 700 miles @ 6.5 cents/mile = $45.50

o       Last 1070 miles @ 6 cents/mile = $64.20

o       Total cost of shipment = $7.50 + $49.00 + $45.50 + $64.20 = $166.20

*If you don't feel like entering the data from the table into an array, you can paste it into word by going Edit, then Paste Special, and choosing unformatted text, then copying each line into VB, and adjusting the entries into your array.

 

*A group of If/Then statements will work.  If the array is called "distance", then it might look like this:

 

If distance > 100 And distance < 801 Then

txtPrice.Text = 100 * 0.075

distance = distance - 100

txtPrice.Text = FormatCurrency(txtPrice.Text + (distance * 0.07))

Exit Sub

End If

 

If distance > 800 And distance < 1501 Then

txtPrice.Text = 100 * 0.075

distance = distance - 100

txtPrice.Text = txtPrice.Text + (700 * 0.07)

distance = distance - 700

txtPrice.Text = FormatCurrency(txtPrice.Text + (distance * 0.065))

Exit Sub

End If

 

This is only part of the code (above) you would need to finish for greater than 1500.

 

On Startup:

  • Suggestion:  load the values into the distance table using the Form_Load event OR declare a module-level table and load the values during the dimensioning of the table.
  • Use combo boxes to store the city names.  No city should be selected in either combo box when the system starts up.

 

During Execution:

  • Distance & Charge button.  The system user will select two cities.  It does not matter if the cities are identical.
    • If one of the combo boxes does not have a city selected, display an appropriate error message, with OK button, and the Error icon in the message box.
    • If both combo boxes have a city selected, display the distance in miles and the charge (formatted as currency).  Your code to display the distance must use one of the programming techniques covered in the notes or textbook for chapter 7 or 8.
  • Clear button.  When clicked, clear both labels that display the distance mileage and charge, and unselect any city selected in the combo boxes and clear any city names displayed in the combo boxes' Text property.
  • Exit button/menu.  Exit the system by closing the form.

 

Assessment of Project.  Your work will be evaluated in terms of major and minor errors.  The point deductions are explained below.  An assessment (test) plan is provided that lists the different types of errors.

  • Major errors – one point is deducted for each major error committed.
  • Minor errors – one point is deducted for having between 1 and 3 minor errors; 2 points are deducted for having between 4 and 6 minor errors; 3 points are deducted for having between 7 and 9 minor errors, and so forth.

 

Test Data.  You must produce test data to test all possible combinations of distance charges.  

 

Test Plan.  This test plan lists the various errors that can occur.  Major errors are indicated by two asterisks **.

 

 

Visual Basic Project Assessment Plan - VB Mail Order Assignment 8

 

Student:_________________________________________________________Possible Points: 20

 

Before startup.

  • Submitted on time without all files necessary to run the project – project is returned for resubmission – this is a major error, when the project is regraded,
  • All files not stored to a folder named VBMailLab8.  Project should be named VBMailLab8.
  • Form has spelling errors. 
  • Form controls are misaligned or improperly sized such that the appearance of the form is NOT pleasing and professional.  Form has too much or not enough white space.
  • Code is not properly indented.
  • Program code is missing sub procedure comments.
  • Program code is missing comments giving the program name, programmer name, and date programmed.
  • Controls are not named following the naming convention specified in the textbook and notes.
  • The mileage table is not implemented as a two-dimensional table **.
  • Fails to use a SELECT-CASE structure as part of the code to compute the mileage charge **.

 

Startup.

  • Form fails to startup centered on the screen.  Form is not an appropriate size.
  • Missing Distance Look Up in the text area at the top of the form.
  • Form erroneously has cities already selected when the system starts up.

 

Distance & Charge button.

  • Computes the incorrect distance or fails to display a distance (double-major error -2).
  • Fails to use one of the programming techniques covered in the notes or textbook for chapter 7 or 8 (quadruple-major error -4).
  • Computes the incorrect charge or fails to display a charge (quadruple-major error -4).
  • Fails to display the charge formatted as currency.
  • When a city is not selected in one of the combo boxes, fails to display a Message Box with the appropriate error message.
  • Message Box has an error message, but is missing the Error icon.
  • Message Box is missing an appropriate title.

 

Clear button.

  • Fails to clear the distance mileage and/or charge labels.
  • Fails to unselect both city combo boxes.
  • Fails to clear the contents of the Text property of the combo boxes.

 

Exit button.  Fails to exit the system.

 

During program execution, the program abnormally terminated (ABEND) due to an error (** -- major error – specify the error):