E-mail Me
Syllabus
Schedule
Handouts
Assignments
All My Webs
Dept Home
|
Programming Assignment 2
Purpose: To demonstrate your ability to use custom
forms, decision and loop structures, and event- and error-handling in
developing applications using Visual Basic for Applications.
You and some friends have decided to start a bicycle courier
service in Fargo-Moorhead. You intend to track orders and costs
using Excel, and need an order input form created using VBA.
You need to record:
- The customer's name
- The pick-up address
- The delivery address
- The number of items to be delivered
- The total weight of the items to be delivered
- The estimated distance between pick-up and delivery
You have decided that cost should be based on the energy
needed to move the packages - weight times distance. For a typical
run, you estimate the cost to be $1.50*(weight in lbs)*(distance in miles),
with a minimum charge of $9.00. So, for example, a 3-lb package,
delivered from downtown Fargo to the Fargo industrial park (about 4 miles)
would cost $1.50*3*4 = $18.00.
You also know that some customers will demand extra service.
You decide that for $2.25/lb-mile, you will guarantee pick-up within 30
minutes (minimum charge - $15.00). You may also arrange for insurance,
if the customer requests, at a charge of 1% of the value of the object.
This program is worth a total of 20 points. In order
to earn 12 of those points, your project must include:
- An input form that includes:
- text boxes to collect:
- the customer's name,
- pick-up address,
- delivery address,
- number of items,
- total weight, and
- delivery distance.
- two option buttons to choose between the regular
service and 30-minute pick-up, and
- a command button marked "OK".
- a command button marked "Close".
- A label to display the calculated cost of delivery.
- A subroutine called by the "OK" button to
determine the cost of the delivery, based on the weight and distance.
Note that the cost must include an "If-Then" structure to
reflect the minimum cost. Display the cost in the label on the form.
- The macro necessary to make the form appear.
To earn 14 points, your program must also include:
- A subroutine called by the "Close"
button that writes the input values and the calulated cost to appropriate
cells on the spreadsheet. It should then make the form disappear.
- A button on the spreadsheet that activates the macro.
To earn 16 points, your project must also include:
- A check box or push button that lets the user select
insurance.
- A text box to enter the estimated value of the objects.
- The cost of insurance in the total cost if the box
is selected
The completed form to this point might look like this:
In order to earn 18 points, your macro must also:
- Include a Do-Loop structure to determine that the "Distance"
box have been filled in.
- When the user presses "OK", the program
should determine if that box is blank..
- If so, a message box should
appear warning the user that that box must be filled in.
- The cursor should move to the empty box, and the
macro should stop.
To earn the full 20 points, your project must also include:
- An event handling subroutine that makes the "Value"
text box appear or disappear based on whether "Insurance"
is selected. (This can't happen only when the OK button is pressed.)
- The option should only appear if the user selects
insurance.
- The cost of the delivery must also include the
cost of insurance, if selected.
|