我在尝试处理 ArgumentNullExeption时遇到问题
值不能为 Null
参数名称项
到目前为止,我尝试了以下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ArgumentNullException As New Boolean
If (ListBox2.Items.Add(ListBox1.SelectedItem.ToString = "")) Then
MessageBox.Show("please pick from list", "error")
End If
ListBox1.Items.Remove(ListBox1.SelectedItem)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ArgumentNullException As New Boolean
If (ListBox2.Items.Add(ListBox1.SelectedItem Is Nothing)) Then
MessageBox.Show("please pick from list", "error")
End If
ListBox1.Items.Remove(ListBox1.SelectedItem)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ArgumentNullException As New BooleanListBox2
ListBox2.Items.Add(ListBox1.SelectedItem)
If (ListBox1.SelectedItem) = ""
MessageBox.Show("please pick from list", "error")
ListBox1.Items.Remove(ListBox1.SelectedItem)
仍然出现错误,请有人帮忙
更新:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox2.Items.Add(ListBox1.SelectedItem)
If IsNothing (ListBox1.SelectedItem)
MessageBox.Show("please pick from list", "error")
ListBox1.Items.Remove(ListBox1.SelectedItem)
仍然给出错误