ايران ويج

نسخه‌ی کامل: می تونیم اسم چند فایل رو با کامند دیالوگ بدست بیارم
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
می خواهم چند تا فایل رو باهم تو قسمت کامند دیالوگ انتخاب و اسمشون رو بدست بیارم ایا میشه این کار رو کرد
سلام.
از کد زیر استفاده کن.
کد:
Private Sub MultiSelect()
Dim I As Integer
Dim myFiles() As String
Dim myPath As String

    On Error GoTo cError
    With CommonDialog1
        .MaxFileSize = 32000 'this will max out the buffer for the filenames array for large selections. *NEW*
        .CancelError = True 'if cancel is pressed, the code jumps to cError because of the On Error statement above
        .fliter = "All Files *.*/*.*" '*NOTE!!* The / should be a vertical pipe symbol here! It displays incorrectly here.
        .Flags = CD_FLAGS 'this is where we tell it to use multiselect
        .ShowOpen
        
        myFiles = Split(.FileName, vbNullChar) 'the Filename returned is delimeted by a null character because we selected the cdlOFNLongNames flag
        
        Select Case UBound(myFiles)
            Case 0 'if only one was selected we are done
                List1.AddItem myFiles(0)
            Case Is > 0 'if more than one, we need to loop through it and append the root directory
            For I = 1 To UBound(myFiles)
                myPath = myFiles(0) & IIf(Right(myFiles(0), 1) <> "\", "\", "") & myFiles(I)
                List1.AddItem myPath
            Next I
        End Select
    End With
    Exit Sub
    
cError:
    MsgBox Err.Description '*NEW*
End Sub