如何检查列表框是否已选中
list1的
checkbox item
checkbox Raja
checkbox Raman
checkbox Vijay
从列表1我想检查是否选中了复选框
如何在vb6中编写代码
需要Vb6代码帮助
答案 0 :(得分:6)
以下是代码:
Private Sub Command1_Click()
If List1.SelCount > 0 Then
MsgBox "Some items are selected"
Else
MsgBox "Sorry,no items are selected !"
End If
End Sub
修改强>
如果您想查找所选项目,可以这样做:
Private Sub Command2_Click()
Dim i As Long
For i = 0 To List1.ListCount - 1 'loop through the items in the ListBox
If List1.Selected(i) = True Then ' if the item is selected(checked)
MsgBox List1.List(i) ' display the item
End If
Next
End Sub