VISUAL BASIC Fast Food Store Group Boxes and Other User Controls Copyright 2014 Dan McElroy Sample Program Execution The customer receipt is updated each time another selection is made and the Enter button is clicked. More than one selection can be made, but the Enter button must be clicked for each selection. The receipt and all selections are cleared when the Clear button is clicked. 1
Label Font Size = 20 Bold 2
GroupBox Text=Sandwich GroupBox Text=Sandwich 3
GroupBox Text=Sandwich Radio Buttons Two more GroupBoxs with RadioButtons or CheckBoxes GroupBox Text=Sandwich Radio Buttons Two more GroupBoxs with RadioButtons or CheckBoxes Check Boxes 4
Buttons Label AutoSize=False BorderStyle = Fixed3D 5
Name Each Object These are the names that I chose. You can choose any names you wish as long as they are descriptive. frmfastfood lbltitle btnclear btnenter btnexit chkcdheese chkfries chkonionrings chktomato radnosandwich radhamburger radchickensandwich radfishsandwich radnodrink radcola radorange radrootbeer lblorderreceipt Sturctured Design Form_Load Event Clear Button Event Enter Button Event Exit Button Event Initialize Variables Clear Receipt Clear Selections Compute Selections Update Receipt Global Constants and Variables 6
Initialize Variables: set all variables to zero Sub Tasks Clear Receipt Set the label used for the receipt to an empty string Clear Selections For each group of RadioButtons, set the Checked property for the None button to True. This will set the Checked property all of the other radio buttons in the group to False For each CheckBox, set its Checked property to False Compute Selections Examine each customer selection (RadioButton or CheckBox), keep a count of the number of times an item from the group has been selected, and add the price of the item to the subtotal. Update Receipt Display the number of items and price for each group, compute and display the subtotal, tax and total The Code (so far) I have completed the code for the sandwiches, the cheese and tomatoes You need to complete the code for drinks and the extras, and any additional code for these items that would be included in the Enter and Clear buttons. 7
Class Level Constants ' Class level Constants Const TAX_RATE As Decimal = 0.0875 ' 8.75% tax rate Const PRICE_HAMBURGER As Decimal = 2.75 Const PRICE_FISH_SANDWICH As Decimal = 3.25 Const PRICE_CHICKEN_SANDWICH As Decimal = 2.49 Const PRICE_CHEESE As Decimal = 0.1 ' 10 cents Const PRICE_TOMATO As Decimal = 0.2 ' 20 cents ' --- You need to include the price of all items Class Level Variables ' Class Level Variables - Count of Each Item Dim countofsandwiches As Integer '--- You need to include the count of each group items ' Class Level Variables - Subtotal, Tax and Total Dim subtotalsandwiches As Decimal Dim subtotaldrinks As Decimal Dim subtotalextras As Decimal Dim subtotal As Decimal Dim tax As Decimal Dim total As Decimal 8
Form_Load Event The Form_Load event occurs when the form is first loaded. The Form_Load event needs to: Initialize the variables Clear the customer selections Clear the customer receipt Individual helper subroutines are provided to implement these tasks. Form_Load Event ' Form Load Event ' Initialize variables and clear the form Private Sub frmfastfood_load(... ) Handles MyBase.Load InitializeVariables() ClearTheCustomerSelections() ClearTheReceipt() End Sub 9
Enter_Button Event The Enter_Button event occurs when Enter button is clicked: Compute the counts and prices of the current selection Update the customer receipt Clear the customer selections Individual helper subroutines are provided to implement these tasks. Enter_Button Event Private Sub btnenter_click(... ) Handles btnenter.click ComputeCurrentSelection() UpdateCustomerReceipt() ClearTheCustomerSelections() End Sub 10
Clear_Button Event The Clear_Button event occurs when Clear button is clicked: The Clear_Button event needs to Initialize the variables Clear the customer selections Clear the customer receipt Individual helper subroutines are provided to implement these tasks. Clear_Button Event The Clear_Button event occurs when Clear button is clicked: The Clear_Button event needs to Initialize the variables Clear the customer selections Clear the customer receipt Individual helper subroutines are provided to implement these tasks. 11
Exit_Button Event The Exit_Button event occurs when Exit button is clicked: The Exit_Button event needs to Quit the program Private Sub btnexit_click(... ) Handles btnexitclick Me.Close() End Sub 12