“打开”对话框同时选择多个文件
【打印文章】
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
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
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】