“打开”对话框同时选择多个文件

发表于:2007-07-14来源:作者:点击数: 标签:
Private Sub Command1_Click() On Error GoTo userCanceled Dim i As Integer With CommonDialog1 .CancelError = True .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks .Filter = 所有文件(*.*)|*.*
Private Sub Command1_Click()
    On Error GoTo userCanceled
    Dim i As Integer
    With CommonDialog1
        .CancelError = True
        .Flags = cdlOFNHideReadOnly Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks
        .Filter = "所有文件(*.*)|*.*"
        .ShowOpen
        GetFileInfo (.FileName)
    End With
    List1.Clear
    For i = 1 To UBound(FileInfo)
        List1.AddItem FileInfo(i)
    Next
    Label3 = FileInfo(0)
userCanceled:
End Sub
Private Sub GetFileInfo(Source As String)
    Dim t As Integer
    FileInfo = Split(Source, Chr(0))
    If UBound(FileInfo) = 0 Then
        ReDim Preserve FileInfo(1)
        t = InStrRev(FileInfo(0), "")
        FileInfo(1) = Mid(FileInfo(0), t + 1)
        FileInfo(0) = Left(FileInfo(0), t)
    Else
        If Right(FileInfo(0), 1) <> "" Then FileInfo(0) = FileInfo(0) & ""
    End If
End Sub

原文转自:http://www.ltesting.net