【发布时间】:2015-03-19 13:55:08
【问题描述】:
当我运行这段代码时,它给了我一个错误,说值不能为空
If (A >= 1) Then
Item1 = fish
ListBox1.Items.Add(Item1)
Else
If (A = 0) Then
If ListBox1.Items.Contains(Item1) = True Then
While ListBox1.Items.Contains(Item1) = True
ListBox1.Items.Remove(Item1)
End While
End If
End If
End If
错误出现在这一行
If ListBox1.Items.Contains(Item1) = True Then
所有的整数都已经变暗了
我想要做的是如果列表框包含第 1 项应该被删除
如果我给 A 值 1 然后将其更改为 0,则代码有效
但如果我从一开始就将 A 值设为 0,代码将崩溃
请帮忙
谢谢
【问题讨论】:
-
因为当时 Item1 是
Nothing所以添加一个检查Nothing。 -
那么你有什么建议可以解决@NikhilAgrawal
-
你能帮我写代码吗@NikhilAgrawal