林有一個問題想處理ArgumentNullExeption發生VB.net零誤差
值不能是空
paramiter名項目
到目前爲止,香港專業教育學院嘗試了以下
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)
A ND錯誤仍然出現任何人都可以幫助請
更新時間:
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)
給出錯誤仍然
這是更好地爲您粘貼整個相關的代碼,比如List變量的初始化。 – PSo
究竟是這樣的:'If(ListBox2.Items.Add(ListBox1.SelectedItem.ToString =「」))Then' ?? –
Noob試驗和錯誤 – shaggs