Purchase Solution

Visual Basic: Supply Cost Calculator Application

Not what you're looking for?

Ask Custom Question

Write an application that calculates the cost of all the supplies added to the user's shopping list (Fig. 22.18). The application should contain two Li stBoxes. The first contains all the supplies offered and their respective prices. Users should be able to select the desired supplies from the first Li stBox and add them to the second Li stBox. Provide a Calculate Button that displays the total price for the user's shopping list (the contents of the second ListBox).

a) Copying the template to your working directory. Copy the directory C: ExamplesTutori al 22Exerci sesSuppl yCal cul ator to your C: Si mpl yVB2008 directory.

b) Opening the application's template file. Double click Suppl yCal cul ator. sl n in the Suppl yCal cul ator directory to open the application.

c) Adding code to the Add >> Button. Double click the Add >> Button to create an empty event handler. Insert code in the event handler that adds the selected item from the first Li stBox to shoppi ngLi stBox. Be sure to check that an item is selected in the first Li stBox before attempting to add an item to shoppi ngLi stBox.

d) Enabling the Buttons. Once the user adds something to the shoppi ngLi stBox, set the Enabl ed properties of the << Remove and Calculate Buttons to True.

e) Deselecting the items. Once the item is added to the shoppi ngLi stBox, make sure that it is deselected in the stockLi stBox. Also, clear the Total: Label to indicate to the user that a new total price must be calculated.

f) Adding code to the << Remove Button. Double click the << Remove Button to create an empty event handler. The Items in your list: Li stBox's Sel ecti onMode property has been set to Mul ti Extended to allow the user to select multiple items. Use a Do Whi l e loop to remove any selected items in the shoppi ngLi stBox. Be sureto check that at least one item is selected before attempting to remove an item. [Hint:Method shoppi ngLi stBox. Items. RemoveAt(i ndex) will remove the item located at i ndex from the shoppi ngLi stBox. When an item is removed, the Sel ectedIndexproperty points to the next selected item, if there is one.] If there are no items remaining in the shoppi ngLi stBox, disable the << Remove and Calculate Buttons.Also, clear the Total: Label to indicate to the user that a new total price must be calculated.

g) Adding code to the Calculate Button. Double click the Calculate Button to create an empty event handler. Use a For... Next statement to loop through all the items in the shoppi ngLi stBox. Convert each item from the Li stBox into a Stri ng. Then use the Stri ng method Substri ng to extract the price of each item.

h) Displaying the total. Convert the Stri ng representing each item's price to a Decimal , and add this to the overall total (of type Deci mal ). Remember to output the value in currency format.

i) Running the application. Select Debug > Start Debugging to run your application. Use the Add >> and << Remove Buttons to add and remove items from the Items in your list: Li stBox. Click the Calculate Button and verify that the total price displayed is correct.

j) Closing the application. Close your running application by clicking its close box.

k) Closing the IDE. Close the Visual Basic IDE by clicking its close box.

Please see the attached MS Word document and the files for further information.

Purchase this Solution

Solution Summary

The supply cost calculator applications for visual basics are examined.

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Javscript Basics

Quiz on basics of javascript programming language.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.