Private Sub Command1_Click()
Dim entries As Variant
Dim dir_name As String
Dim i As Integer
On Error Resume Next
dlgFiles.ShowOpen
If Err.Number = cdlCancel Then
Exit Sub
ElseIf Err.Number <> 0 Then
MsgBox "Error " & Format$(Err.Number) & _
" selecting files." & vbCrLf & Err.Description
Exit Sub
End If
List1.Clear
entries = Split(dlgFiles.FileName, vbNullChar)
' See if there is more than one file.
If UBound(entries, 1) = LBound(entries, 1) Then
' There is only one file name.
List1.AddItem entries(LBound(entries, 1))
Else
' Get the directory name.
dir_name = entries(LBound(entries, 1))
If Right$(dir_name, 1) <> "\" Then dir_name = _
dir_name & "\"
' Get the file names.
For i = LBound(entries, 1) + 1 To UBound(entries, 1)
List1.AddItem dir_name & entries(i)
Next i
End If
End Sub
|