Code:
Private Sub purbtn_Click(sender As Object, e As EventArgs) Handles purbtn.Click
'declaring that the prices are numbers and that there is 5 of them
Dim prices1(2) As Integer
Dim prices2(4) As Integer
prices1(0) = 20
prices1(1) = 20
prices1(2) = 20
prices2(0) = 11
prices2(1) = 15
prices2(2) = 20
prices2(3) = 50
prices2(4) = 90
Dim allPrices(1)() As Integer
allPrices(0) = prices1
allPrices(1) = prices2
Dim listBoxes() As ListBox = {ListBox1, ListBox2}
Dim total As Integer = 0
'making sure they all add up properly in a specified text box based on which one was highlighted
For x As Integer = 0 To listBoxes.GetUpperBound(0)
For y As Integer = 0 To listBoxes(x).Items.Count - 1
If listBoxes(x).SelectedIndices.Contains(y) Then
total += allPrices(x)(y)
End If
Next
Next
'declaring that ticking that will add 50 pounds to the total
If CheckBox1.Checked = False Then
TextBox1.Text = total.ToString("c2")
End If
If CheckBox1.Checked = True Then
total += 50
End If
TextBox1.Text = total.ToString("c2")
If total >= 200 Then
Dim discountedTotal As Decimal = CDec(total * 0.9)
TextBox3.Text = discountedTotal.ToString("c2")
End If
End Sub