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
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/