0

リストボックスがチェックされているかどうかを確認する方法

リスト1

checkbox item

checkbox   Raja
checkbox   Raman
checkbox   Vijay

リスト1からチェックボックスがチェックされているかどうかを確認したい

vb6でコードを書く方法

Vb6 コードのヘルプが必要

4

1 に答える 1

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
于 2012-07-16T07:32:19.743 に答える