I am making a project for school with visual basic and its a mcdonalds ordering system. There are 50+ buttons which you can press to remove an item and my code works fine. only problem is it is waaaaayyyy to long and can be shortened with a wildcard. Does anyone know what a good way to put a wildcard in the following code would be:
Private Sub btnsmallfries_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsmallfries.Click
If Label2.Text = "Buy Mode" Then
lstorders.Items.Remove("Small Fries $1.95 x1")
lstorders.Items.Remove("Small Fries $1.95 x2")
lstorders.Items.Remove("Small Fries $1.95 x3")
lstorders.Items.Remove("Small Fries $1.95 x4")
lstorders.Items.Remove("Small Fries $1.95 x5")
lstorders.Items.Remove("Small Fries $1.95 x6")
lstorders.Items.Remove("Small Fries $1.95 x7")
lstorders.Items.Remove("Small Fries $1.95 x8")
lstorders.Items.Remove("Small Fries $1.95 x9")
lstorders.Items.Remove("Small Fries $1.95 x10")
totalprice = totalprice + 3.25
txtcost.Text = ("$" & totalprice & "")
smallfriescount = smallfriescount + 1
lstorders.Items.Add("Small Fries $1.95 x" & smallfriescount & "")
End If
If Label2.Text = "Sell Mode" Then
lstorders.Items.Remove("Small Fries $1.95 x1")
lstorders.Items.Remove("Small Fries $1.95 x2")
lstorders.Items.Remove("Small Fries $1.95 x3")
lstorders.Items.Remove("Small Fries $1.95 x4")
lstorders.Items.Remove("Small Fries $1.95 x5")
lstorders.Items.Remove("Small Fries $1.95 x6")
lstorders.Items.Remove("Small Fries $1.95 x7")
lstorders.Items.Remove("Small Fries $1.95 x8")
lstorders.Items.Remove("Small Fries $1.95 x9")
lstorders.Items.Remove("Small Fries $1.95 x10")
totalprice = totalprice - 3.25
txtcost.Text = ("$" & totalprice & "")
smallfriescount = smallfriescount - 1
If smallfriescount = 0 Then
Else
lstorders.Items.Add("Small Fries $1.95 x" & smallfriescount & "")
End If
End If
End Sub
Private Sub btnsmallfries_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsmallfries.Click
If Label2.Text = "Buy Mode" Then
lstorders.Items.Remove("Small Fries $1.95 x1")
lstorders.Items.Remove("Small Fries $1.95 x2")
lstorders.Items.Remove("Small Fries $1.95 x3")
lstorders.Items.Remove("Small Fries $1.95 x4")
lstorders.Items.Remove("Small Fries $1.95 x5")
lstorders.Items.Remove("Small Fries $1.95 x6")
lstorders.Items.Remove("Small Fries $1.95 x7")
lstorders.Items.Remove("Small Fries $1.95 x8")
lstorders.Items.Remove("Small Fries $1.95 x9")
lstorders.Items.Remove("Small Fries $1.95 x10")
totalprice = totalprice + 3.25
txtcost.Text = ("$" & totalprice & "")
smallfriescount = smallfriescount + 1
lstorders.Items.Add("Small Fries $1.95 x" & smallfriescount & "")
End If
If Label2.Text = "Sell Mode" Then
lstorders.Items.Remove("Small Fries $1.95 x1")
lstorders.Items.Remove("Small Fries $1.95 x2")
lstorders.Items.Remove("Small Fries $1.95 x3")
lstorders.Items.Remove("Small Fries $1.95 x4")
lstorders.Items.Remove("Small Fries $1.95 x5")
lstorders.Items.Remove("Small Fries $1.95 x6")
lstorders.Items.Remove("Small Fries $1.95 x7")
lstorders.Items.Remove("Small Fries $1.95 x8")
lstorders.Items.Remove("Small Fries $1.95 x9")
lstorders.Items.Remove("Small Fries $1.95 x10")
totalprice = totalprice - 3.25
txtcost.Text = ("$" & totalprice & "")
smallfriescount = smallfriescount - 1
If smallfriescount = 0 Then
Else
lstorders.Items.Add("Small Fries $1.95 x" & smallfriescount & "")
End If
End If
End Sub