Reputation: 1
My code:
If Form3.lstOrder.SelectedItem = "Chicken" Then
total -= ChickenPrice
Form3.txtTotal.Text = total
End If
The program is supposed to read the selected item in the ListBox
and compare to see if it matches 'chicken'; if it is chicken, the price of chicken is then removed from the order total.
However this does not work, can anyone help?
Upvotes: 0
Views: 296
Reputation: 4253
The .SelectedItem
property is of type Object, (as opposed to String), and you're trying to compare it directly to a String.
Do this instead:
If Form3.lstOrder.SelectedItem.ToString() = "Chicken" Then
total -= ChickenPrice
Form3.txtTotal.Text = total
End If
Here's a reference that may help, as well:
Upvotes: 1