home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
- Begin VB.Form MultipleFiles
- Caption = "Multiple File Selection with File Open the Common Dialog Control"
- ClientHeight = 3720
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 6810
- LinkTopic = "Form1"
- ScaleHeight = 3720
- ScaleWidth = 6810
- StartUpPosition = 3 'Windows Default
- Begin VB.ListBox List1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 2580
- Left = 3030
- TabIndex = 1
- Top = 990
- Width = 3645
- End
- Begin VB.CommandButton Command1
- Caption = "Select Multiple Files"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 510
- Left = 165
- TabIndex = 0
- Top = 3060
- Width = 2340
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 1215
- Top = 1770
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- End
- Begin VB.Label Label2
- Caption = "Selected Path"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 270
- Left = 150
- TabIndex = 3
- Top = 195
- Width = 1860
- End
- Begin VB.Label Label1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 330
- Left = 135
- TabIndex = 2
- Top = 480
- Width = 6195
- End
- Attribute VB_Name = "MultipleFiles"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Private Sub Command1_Click()
- CommonDialog1.Flags = cdlOFNAllowMultiselect
- Label1.Caption = ""
- List1.Clear
- CommonDialog1.Filter = "All Files|*.*"
- CommonDialog1.ShowOpen
- filenames = CommonDialog1.FileName
- If Len(filenames) = 0 Then
- MsgBox "No files selected"
- Exit Sub
- End If
- ' Extract path name:
- ' IF FILETITLE IS NOT EMPTY, THEN A SINGLE FILE
- ' HAS BEEN SELECTED. DISPLAY IT AND EXIT
- If CommonDialog1.FileTitle <> "" Then
- List1.AddItem CommonDialog1.FileTitle
- Exit Sub
- End If
- ' FILETITLE IS NOT EMPTY, THEN MANY FILES WERE SELECTED
- ' AND WE MUST EXTRACT THEM FROM THE FILENAME PROPERTY
- spPosition = InStr(filenames, " ")
- pathName = Left(filenames, spPosition - 1)
- Label1.Caption = pathName
- filenames = Mid(filenames, spPosition + 1)
- ' then extract each space delimited file name
- If Len(filenames) = 0 Then
- List1.AddItem "No files selected"
- Exit Sub
- Else
- spPosition = InStr(filenames, " ")
- While spPosition > 0
- List1.AddItem Left(filenames, spPosition - 1)
- filenames = Mid(filenames, spPosition + 1)
- spPosition = InStr(filenames, " ")
- Wend
- ' Add the last file's name to the list
- ' (the last file name isn't followed by a space)
- List1.AddItem filenames
- End If
- End Sub
-