How are you,
I created a simple cash register code that makes the user selects the order from different buttons. I have some problem figuring out the following:
1. How can I get the total (if the user selects 1 or 2 or 3 different orders). I need to find out the total no matter what the user selects and presses (ButtonDone) with the tax added. I could not figure out how to add the arrays based on the user selection.
2. I need to clear the (TextBoxBill) when the user selects New Order (ButtonNewOrder)
3. I managed to get a new line for each order but everytime I select the (ButtonBurger), the menu of the order disappears and only the (Hamburger) is shown in the first line of the (TextboxBill). In other words, if the users select different orders then they select (Hamburger) at the end, all the previous orders disappear and (Hamburger appears in the beginning. (I attached the pictures for clarifying the probelm).
I am totally new in programming and I'm trying to learn as much as I can.
Thank you in advance for any comments / help.
Public Class CashRegister
Structure MenuItems
Dim ItemName As String
Dim ItemCost As Decimal
Dim Total As Decimal
End Structure
Private OrderMenu(6) As MenuItems
Private Sub CashRegister_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub ButtonBurger_Click(sender As System.Object, e As System.EventArgs) Handles ButtonBurger.Click
Dim TotalCost As Decimal
OrderMenu(1).ItemName = "Hamburger"
OrderMenu(1).ItemCost = 4.95
TotalCost += OrderMenu(1).ItemCost
LabelCost.Text = TotalCost
TextBoxBill.Text = OrderMenu(1).ItemName.ToString & vbTab & OrderMenu(1).ItemCost.ToString & vbCrLf
End Sub
Private Sub ButtonCheeseburger_Click(sender As System.Object, e As System.EventArgs) Handles ButtonCheeseburger.Click
Dim TotalCost As Decimal
OrderMenu(2).ItemName = "Cheeseburger"
OrderMenu(2).ItemCost = 5.95
TotalCost += OrderMenu(2).ItemCost
LabelCost.Text = TotalCost
TextBoxBill.Text += OrderMenu(2).ItemName.ToString & vbTab & OrderMenu(2).ItemCost.ToString & vbCrLf
End Sub
Private Sub ButtonFries_Click(sender As System.Object, e As System.EventArgs) Handles ButtonFries.Click
Dim TotalCost As Decimal
OrderMenu(3).ItemName = "Fries"
OrderMenu(3).ItemCost = 1.99
TotalCost += OrderMenu(3).ItemCost
LabelCost.Text = TotalCost
TextBoxBill.Text += OrderMenu(3).ItemName.ToString & vbTab & vbTab & OrderMenu(3).ItemCost.ToString & vbCrLf
End Sub
Private Sub ButtonOnionRings_Click(sender As System.Object, e As System.EventArgs) Handles ButtonOnionRings.Click
Dim TotalCost As Decimal
OrderMenu(4).ItemName = "Oinion Rings"
OrderMenu(4).ItemCost = 2.99
TotalCost += OrderMenu(4).ItemCost
LabelCost.Text = TotalCost
TextBoxBill.Text += OrderMenu(4).ItemName.ToString & vbTab & OrderMenu(4).ItemCost.ToString & vbCrLf
End Sub
Private Sub ButtonSoda_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSoda.Click
Dim TotalCost As Decimal
OrderMenu(5).ItemName = "Soda"
OrderMenu(5).ItemCost = 0.99
TotalCost += OrderMenu(5).ItemCost
LabelCost.Text = TotalCost
TextBoxBill.Text += OrderMenu(5).ItemName.ToString & vbTab & vbTab & OrderMenu(5).ItemCost.ToString & vbCrLf
End Sub
Private Sub ButtonBeer_Click(sender As System.Object, e As System.EventArgs) Handles ButtonBeer.Click
Dim TotalCost As Decimal
OrderMenu(6).ItemName = "Beer"
OrderMenu(6).ItemCost = 4.99
TotalCost += OrderMenu(6).ItemCost
LabelCost.Text = TotalCost
TextBoxBill.Text += OrderMenu(6).ItemName.ToString & vbTab & vbTab & OrderMenu(6).ItemCost.ToString & vbCrLf
End Sub
Private Sub ButtonDone_Click(sender As System.Object, e As System.EventArgs) Handles ButtonDone.Click
'Adds the total or the order and prints the tax
Dim Subtotal As Decimal
Dim Tax As Decimal
' Subtotal or the selected order
' add tax
End Sub
Private Sub ButtonNewOrder_Click(sender As System.Object, e As System.EventArgs) Handles ButtonNewOrder.Click
'Clears the TexBoxBill and start new order
End Sub
Private Sub TextBoxBill_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBoxBill.TextChanged
End Sub
End Class