SelMultiFile




Private Sub Form_Load()
dlgFiles.CancelError = True
dlgFiles.Flags = _
cdlOFNExplorer + _
cdlOFNFileMustExist + _
cdlOFNAllowMultiselect
dlgFiles.InitDir = App.Path
dlgFiles.Filter = _
"Text Files (*.txt)|*.txt|" & _
"All Files (*.*)|*.*"
dlgFiles.FilterIndex = 2
End Sub

Private Sub Command1_Click()
Dim pos As Integer
Dim txt As String
Dim dir_name As String
Dim file_name As String

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
txt = dlgFiles.FileName

' See if there is more than one file.

pos = InStr(txt, vbNullChar)
If pos = 0 Then
' There is only one file name.

List1.AddItem txt
Else
' Get the directory name.

dir_name = Left$(txt, pos - 1)
If Right$(dir_name, 1) <> "\" Then dir_name = dir_name & "\"
txt = Mid$(txt, pos + 1)

' Get the file names.

Do While Len(txt) > 0
pos = InStr(txt, vbNullChar)
If pos = 0 Then
file_name = txt
txt = ""
Else
file_name = Left$(txt, pos - 1)
txt = Mid$(txt, pos + 1)
End If
List1.AddItem dir_name & file_name
Loop
End If
End Sub










( selmultifile.html )- by Paolo Puglisi - Modifica del 17/12/2023