您的位置:首页 > 编程语言 > VB

如何在VB 中直接打开并选择目录,而不使用麻烦的多个控件?

2010-03-26 16:45 495 查看
之前使用过一种方法,很简单,在VB6 或 VBA 中均可使用,代码如下:

* 但有一个前提条件,因使用到 Shell32.DLL ,故必须先引用 "Microsoft Shell Controls And Automation" 才可以正常使用。

Dim objShell As New Shell32.Shell
Dim oFd As Shell32.Folder2

Set oFd = objShell.BrowseForFolder(Me.Hwnd, "Please choice the folder include target excel files.", 16 + 64)
If Not oFd Is Nothing Then
txtFolder.Text = IIf(Right(oFd.Self.Path, 1) = "/", oFd.Self.Path, oFd.Self.Path & "/")
Else
Exit Sub
End If
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐