Hai,
i am working on windows applications. In my applicaion One combobox, one button(neamed as delete) is there.
I would like to delete the selected combobox item .So I wrote code to delete a selected item under delete button click. In this i want to check if the combobox selected item is null, after clicking on the button delete it displays some error message like, "There is no item to delete. You selected nothing."
i wrote this code
[code=vbnet]
If (ComboBox1.Item s.Count = 0) Then
MessageBox.Show ("There are no items in the combobox")
Else
Dim str As String
str = ComboBox1.Selec tedItem
If (str.Equals(Not hing)) Then
MessageBox.Show (" No item is selceted", "", MessageBoxButto ns.OK, MessageBoxIcon. Error)
Else
count = count - 1
ComboBox1.Items .Remove(str21)
End If
End If
[/code]
But it gives an error at If(str.Equals(N othing)) then this line.The error is Object reference is not set to an instance of object.can you help me?
i am working on windows applications. In my applicaion One combobox, one button(neamed as delete) is there.
I would like to delete the selected combobox item .So I wrote code to delete a selected item under delete button click. In this i want to check if the combobox selected item is null, after clicking on the button delete it displays some error message like, "There is no item to delete. You selected nothing."
i wrote this code
[code=vbnet]
If (ComboBox1.Item s.Count = 0) Then
MessageBox.Show ("There are no items in the combobox")
Else
Dim str As String
str = ComboBox1.Selec tedItem
If (str.Equals(Not hing)) Then
MessageBox.Show (" No item is selceted", "", MessageBoxButto ns.OK, MessageBoxIcon. Error)
Else
count = count - 1
ComboBox1.Items .Remove(str21)
End If
End If
[/code]
But it gives an error at If(str.Equals(N othing)) then this line.The error is Object reference is not set to an instance of object.can you help me?
Comment