473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Lunch order application

1
I only manage to do this assignment using combo box anyone has any idea to do this using option box???

Specifications

Create a form based application that resembles the above figure. For each order, the user selects one main course item and zero or more of the associated add-ons. When the user clicks on the Place Order button, the application displays the sub total, tax, and total due for the order. It also enables the Print Receipt button. To print a copy of the lunch order form, the user can click on the Print Receipt button. This also clears the add-on check boxes and resets the Main course option button to Hamburger.

For the three add-ons and prices change based on the main course item that’s selected. For a hamburger, the three items are: (1) Lettuce, tomato, and onions; (2) Mayonnaise and mustard; and (3) French fries. The price of each is 75 cents. For a pizza, the three items are: (1) Pepperoni, (2) Sausage, and (3) Olives. The price of each is 50 cents. For a salad, the three items are the ones shown above and the price of each is 25 cents.
The sub total is equal to the cost of the main course item, plus the cost of the
Add-ons. The tax is the sub total * .0785. And the total due is the sub total + tax. To print a copy of the lunch order form when the user clicks on the Print Receipt button, you can use the PrintForm method of the form object.

Thank you

These are my code
Expand|Select|Wrap|Line Numbers
  1. Const NAME_POS = 0
  2. Const ADDON_PRICE_POS = 1
  3. Const MAIN_PRICE_POS = 2
  4. Const ADDON_ARRAY_POS = 3
  5.  
  6. Const TAX_RATE = 0.0785
  7.  
  8. Dim Products(2, 3) As Variant
  9. Dim HamburgerAddOns(0 To 2) As String
  10. Dim PizzaAddOns(0 To 2) As String
  11. Dim SaladAddOns(0 To 2) As String
  12.  
  13. Private Sub Form_Load()
  14.     InitArrays
  15.     InitCboMainCourse
  16.     ResetForm
  17. End Sub
  18.  
  19. Private Sub InitArrays()
  20.     Products(0, NAME_POS) = "Hamburger"
  21.     Products(1, NAME_POS) = "Pizza"
  22.     Products(2, NAME_POS) = "Salad"
  23.  
  24.     Products(0, ADDON_PRICE_POS) = CCur(0.75)
  25.     Products(1, ADDON_PRICE_POS) = CCur(0.5)
  26.     Products(2, ADDON_PRICE_POS) = CCur(0.25)
  27.  
  28.     Products(0, MAIN_PRICE_POS) = CCur(6.95)
  29.     Products(1, MAIN_PRICE_POS) = CCur(5.95)
  30.     Products(2, MAIN_PRICE_POS) = CCur(4.95)
  31.  
  32.     HamburgerAddOns(0) = "Lettuce, Tomato, and Onions"
  33.     HamburgerAddOns(1) = "Mayonnaise and Mustard"
  34.     HamburgerAddOns(2) = "French fries"
  35.     Products(0, ADDON_ARRAY_POS) = HamburgerAddOns
  36.  
  37.     PizzaAddOns(0) = "Pepperoni"
  38.     PizzaAddOns(1) = "Sausage"
  39.     PizzaAddOns(2) = "Olives"
  40.     Products(1, ADDON_ARRAY_POS) = PizzaAddOns
  41.  
  42.     SaladAddOns(0) = "Croutons"
  43.     SaladAddOns(1) = "Bacon bits"
  44.     SaladAddOns(2) = "Bread stick"
  45.     Products(2, ADDON_ARRAY_POS) = SaladAddOns
  46. End Sub
  47.  
  48. Private Sub InitCboMainCourse()
  49.     Dim i As Integer
  50.  
  51.     For i = LBound(Products, 1) To UBound(Products, 1)
  52.         cboMainCourse.AddItem Products(i, NAME_POS)
  53.     Next
  54. End Sub
  55.  
  56. Private Sub ResetForm()
  57.     cboMainCourse.ListIndex = 0
  58.     cmdPrintReceipt.Enabled = False
  59. End Sub
  60.  
  61. Private Sub cboMainCourse_Click()
  62.     Dim i As Integer
  63.  
  64.     cmdPrintReceipt.Enabled = False
  65.  
  66.     For i = chkAddOn.LBound To chkAddOn.UBound
  67.         chkAddOn(i).Value = vbUnchecked
  68.         chkAddOn(i).Caption = Products(cboMainCourse.ListIndex, ADDON_ARRAY_POS)(i)
  69.     Next
  70. End Sub
  71.  
  72. Private Sub cmdPlaceOrder_Click()
  73.     DisplayReceipt
  74.     cmdPrintReceipt.Enabled = True
  75. End Sub
  76.  
  77. Private Sub cmdPrintReceipt_Click()
  78.     Me.PrintForm
  79.     ResetForm
  80. End Sub
  81.  
  82. Private Sub cmdExit_Click()
  83.     Unload Me
  84. End Sub
  85.  
  86. Private Sub DisplayReceipt()
  87.     Dim curSubTotal As Currency
  88.     Dim curTax As Currency
  89.     Dim intAddOnCount As Integer
  90.     Dim i As Integer
  91.     Dim intSelectedProduct As Integer
  92.  
  93.     intSelectedProduct = cboMainCourse.ListIndex
  94.  
  95.     For i = chkAddOn.LBound To chkAddOn.UBound
  96.         If chkAddOn(i).Value = vbChecked Then
  97.             intAddOnCount = intAddOnCount + 1
  98.         End If
  99.     Next
  100.  
  101.     curSubTotal = CCur(Products(cboMainCourse.ListIndex, MAIN_PRICE_POS) _
  102.      + intAddOnCount * Products(intSelectedProduct, ADDON_PRICE_POS))
  103.  
  104.     curTax = curSubTotal * TAX_RATE
  105.  
  106.     lblSubtotal.Caption = CStr(FormatCurrency(curSubTotal, 2))
  107.     lblTax.Caption = CStr(FormatCurrency(curTax, 2))
  108.     lblTotal.Caption = CStr(FormatCurrency(curSubTotal + curTax, 2))
  109. End Sub
Oct 30 '08 #1
0 1401

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Nancy | last post by:
Hi, Guys, Is there any other way to use python or mod_python writing a web page? I mean, not use "form.py/email", no SMTP server. <form action="form.py/email" method="POST"> ... Thanks a lot. ...
3
by: Michael | last post by:
Hi, I have a windows service developed using c# and it needs to lunch another windows application. I have been trying to use Process class to do it but the problem is becase windows service...
2
by: NeilS | last post by:
I'm developing under IIS V5.1 and testing on an ethernet with IIS hosted on WinXPPro. I am trying to implement file-upload using a polished version of the technique published in...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
0
by: Mike John | last post by:
I trying to lunch the send page function the explore browser. I want to send the page in the body of the email I tried using the send keys (to launch the send page function), but I am receiving...
2
by: Jensen bredal | last post by:
Hello, I need to hide the toolbar of my aspx page and resize it on start up? How can this be done? Many thanks in advance JB
1
by: Jim Heavey | last post by:
If I place a stop on a line of code, the application stops at the designated line of code, but when I press the button to advance to the next line of code, it takes about 20 seconds for the system...
104
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
3
by: Hartmut Dippon | last post by:
Hi all, I hope somebody can help me with following problem: I have an application where I can drag&drop files/dirs from within explorer onto my form. If multiple files/dirs are selected I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.