VB中如何判断列表框中是否有内容?

来源:百度知道 编辑:UC知道 时间:2024/06/21 03:36:47
假设左边做了一个列表框,右边有一个按钮.按钮的功能是删除左边列表框中选定的内容.但是如果没选定内容,却按了右边的按钮,我就想要它弹出一个信息框,如"请选定要删除的项".这个怎么做来着?

If List1.SelCount = 0 Then
MsgBox "请选择要删除的项"
End If

private sub command1_click()
for i=0 to list1.listcount-1
if list1.selected(i)=true then
'代码
exit sub
end if
next
msgbox"请选择要删除的项"
end sub

VB 是什么东西?