用api速度可以快一些:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_GETSELITEMS = &H191
Private Const LB_GETSELCOUNT = &H190
Private Sub Command1_Click()
Dim items() As Long
Dim numsel As Long
Dim c As Long
Dim retval As Long
numsel = SendMessage(File1.hwnd, LB_GETSELCOUNT, ByVal CLng(0), ByVal CLng(0))
If numsel = 0 Then
Debug.Print "没有文件被选中"
Else
ReDim items(0 To numsel - 1) As Long
retval = SendMessage(File1.hwnd, LB_GETSELITEMS, ByVal numsel, items(0))
' Display them.
Debug.Print "选中了以下文件:"
For c = 0 To UBound(items)
Debug.Print File1.List(items(c))
Next
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount-1
If File1.Selected(i) = True Then
Text1.Text = Text1.Text & " " & File1.List(i)
End If
Next i
End Sub
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount-1
If File1.Selected(i) = True Then
Text1.Text = Text1.Text & " " & File1.List(i)
End If
Next i
End Sub