jeudi 15 octobre 2020

Why can't I do comparison in VB.net?

If (cmbBloodgroup.SelectedItem == null) Then
            MessageBox.Show("Please select a blood group.")
Endif

The error 'Expression expected' is on the second equal sign. When I clicked the 'Show potential fixes', it gave me 2 options: remove unnecessary parentheses, and invert if. The first option doesn't remove the error. The second option makes it like this:

cmbBloodgroup.SelectedItem =IsNot null

But I want the condition for it to be null. Idk what I should change here. (I'm checking combobox. If it's empty, I want to show a messagebox)

Aucun commentaire:

Enregistrer un commentaire