I have i remove button in my program which removes a selected item from the list box. But i don't know how can i get the program to remove the selected item along with subtracting the cost of that item when i click on the remove button.
This is my code for the remove button.
listbox1.Items.Remove(listbox1.Text)
This is the code i used to add the cost of selected items in the listbox and this code is in a module.
Public Pizza() As String = {"BBQ Meatlovers", "Supreme", "Double Bacon Cheeseburger", "Godfather", "Firebreather", "Blue Cheese & Bacon", "Vegorama", "Bangers & Beef", "Champagne Ham & Cheese", "Hawaiian", "Pepperoni", "Simply Cheese", "Beef & Onion", "Veg Trio"}
Public RegularPizza As Double = 8.5
Public GourmetPizza As Double = 13.5
Dim TotalDelivery As Double = 3.0
For x As Integer = 0 To (listbox1.Items.Count - 1)
If listbox1.Items(x) = Pizza(0) Or listbox1.Items(x) = Pizza(1) Or listbox1.Items(x) = Pizza(2) Or listbox1.Items(x) = Pizza(3) Or listbox1.Items(x) = Pizza(4) Then
TotalDelivery += RegularPizza
Else
TotalDelivery += GourmetPizza
End If
Next
label1.Text = TotalDelivery.ToString("C")
This is my code for the remove button.
listbox1.Items.Remove(listbox1.Text)
This is the code i used to add the cost of selected items in the listbox and this code is in a module.
Public Pizza() As String = {"BBQ Meatlovers", "Supreme", "Double Bacon Cheeseburger", "Godfather", "Firebreather", "Blue Cheese & Bacon", "Vegorama", "Bangers & Beef", "Champagne Ham & Cheese", "Hawaiian", "Pepperoni", "Simply Cheese", "Beef & Onion", "Veg Trio"}
Public RegularPizza As Double = 8.5
Public GourmetPizza As Double = 13.5
Dim TotalDelivery As Double = 3.0
For x As Integer = 0 To (listbox1.Items.Count - 1)
If listbox1.Items(x) = Pizza(0) Or listbox1.Items(x) = Pizza(1) Or listbox1.Items(x) = Pizza(2) Or listbox1.Items(x) = Pizza(3) Or listbox1.Items(x) = Pizza(4) Then
TotalDelivery += RegularPizza
Else
TotalDelivery += GourmetPizza
End If
Next
label1.Text = TotalDelivery.ToString("C")