VB 浏览文件夹 记录一下
- 点滴记录
- 2020-12-14
- 2479
Public Function ShowFolderDialog( As String'/最简单的显示文件夹选择对话框方法Dim spShell, spFol...
Public Function ShowFolderDialog() As String
'/最简单的显示文件夹选择对话框方法
Dim spShell, spFolder, spFolderItem, spPath As String
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set spShell = CreateObject("Shell.Application")
Set spFolder = spShell.BrowseForFolder(WINDOW_HANDLE, "选择目录:", NO_OPTIONS, "C:\Scripts")
If spFolder Is Nothing Then
ShowFolderDialog = ""
Else
Set spFolderItem = spFolder.Self
spPath = spFolderItem.path
spPath = Replace(spPath, "\", "\")
ShowFolderDialog = spPath
End If
End Function
Private Sub Command1_Click()
Dim path As String
path = ShowFolderDialog()
MsgBox IIf(Len(path) = 0, "你点击了取消按钮!", "你选择的文件夹是:" & path)
End Sub
本篇文章由柠檬小张于2020-12-14发表,转载请注明出处:柠檬小张。如本文侵犯了您的权益,请及时联系我们。如果有需求,请下方留言,看到后邮件发送。
本文链接:http://zxmcloud.com/?id=32
本文链接:http://zxmcloud.com/?id=32
上一篇:vb检测更新文件
下一篇:自制中介房产管理软件
发表评论