不好意思,判断写错了。For i = 0 To List1.ListCount - 1 If List1.Selected(i) Then MsgBox List1.List(i) End If Next
用API: Public Const LB_GETCURSEL = &H188 Public Const LB_GETSELITEMS = &H191 Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long 1.Single Selected ListBox iSelected=SendMessage(ListBox.hwnd, LB_GETCURSEL, 0, 0)2.Multi-Selected ListBox Dim nSelCount As Integer nSelCount = ListBox.SelCount Dim nSelIndex() As Long ReDim nSelIndex(1 To nSelCount) SendMessage ListBox.hwnd, LB_GETSELITEMS, nSelCount, nSelIndex(1) 存在数组nSelIndex()中
For i = 0 To List1.ListCount - 1 If List1.Checked(i) Then '不是复选框时用Selected,是复选框时用Checked MsgBox List1.List(i) End If Next
If List1.Selected(i) Then
MsgBox List1.List(i)
End If
Next
Public Const LB_GETCURSEL = &H188
Public Const LB_GETSELITEMS = &H191
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
1.Single Selected ListBox
iSelected=SendMessage(ListBox.hwnd, LB_GETCURSEL, 0, 0)2.Multi-Selected ListBox
Dim nSelCount As Integer nSelCount = ListBox.SelCount Dim nSelIndex() As Long
ReDim nSelIndex(1 To nSelCount) SendMessage ListBox.hwnd, LB_GETSELITEMS, nSelCount, nSelIndex(1)
存在数组nSelIndex()中
If List1.Checked(i) Then '不是复选框时用Selected,是复选框时用Checked
MsgBox List1.List(i)
End If
Next