Vb6 如何检查列表框是否已选中

Vb6 如何检查列表框是否已选中,vb6,Vb6,如何检查列表框是否选中 清单1 从列表1中,我想检查是否选中了复选框 如何在vb6中编写代码 需要Vb6代码帮助以下是代码: 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 编辑 如果要查

如何检查列表框是否选中

清单1

从列表1中,我想检查是否选中了复选框

如何在vb6中编写代码

需要Vb6代码帮助

以下是代码:

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
代码如下:

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