Matt142 Matt142 - 9 days ago 5
Vb.net Question

Combobox returning null when it's not?

I have the following if statement:

If line.Contains(":") And Not line.Contains(removeCombo.SelectedItem) Then
file2.WriteLine(line)
End If


removeCombo being the combobox and the variable 'line' being the current line in a file. The if statement returns 'Value Cannot Be Null.' Why is this? I have also chosen a value in the combobox.

Answer

try replacing:

   removeCombo.SelectedItem 

with:

removeCombo.Text
Comments