The list box part (shortened to fit), this part works
Dim LineItem As RestaurantMenuItem LineItem = New RestaurantMenuItem LineItem.Name = "Item One" LineItem.Price = 1.00 CafeMenu.Add(LineItem) For Each LineItem In CafeMenu ListBox1.Items.Add(LineItem.Name) ListBox2.Items.Add(LineItem.Price)
The calculate button:
Dim orderItem As RestaurantMenuItem Dim Total As Double For Each orderItem In Order subTotal += orderItem.Price lblTotal.Text = total
Again, this works.
Now, the part that does NOT work:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ListBox3.Items.Clear() lblTotal.Text = "____________" End Sub
This is supposed to clear it.
It empties the listbox and sets the cost label to 0, but it doesn't reset the cost. If I add a 1.00 item, click calc, clear it, add a 1.00 item and calc again, it's 2.00, because it still keeps the 1.00 from the first time.
I've tried a few things
1) I've tried setting total = 0 after the calculations
2) I've tried declaring total as a public double but that causes the calculate functions to not work
3) I've tried setting total = 0 in the clear button but I get the error that total is not declared.