vb.net 如何知道列表框是否为空
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33183984/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How To Know If the listbox is empty
提问by NewProg
sir how can i know if my listbox is empty or not?
先生,我怎么知道我的列表框是否为空?
i dont really have an idea for that. i'd try this but its wrong if listbox1.items = "" end if
我真的没有这个想法。我会尝试这个,但如果 listbox1.items = "" end if 是错误的
thank you
谢谢你
回答by pg0xC
There is a property ListBox.Items and you should try if Count is greater than 0 example:
有一个 ListBox.Items 属性,如果 Count 大于 0,您应该尝试:
If ListBox1.Items.Count > 0 Then
YOURCODE
END IF
You should always use msdn library to check simple things like that. For example link to ListBox documentation is under https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox(v=vs.110).aspx
您应该始终使用 msdn 库来检查诸如此类的简单事情。例如,ListBox 文档的链接位于https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox(v=vs.110).aspx

