VB选择文件夹代码

Public shlShell As Shell32.Shell
Public shlFolder As Shell32.Folder
Const BIF_RETURNONLYFSDIRS = &H1

Private Sub cmdOpen_Click()
    If shlShell Is Nothing Then
         Set shlShell = New Shell32.Shell
    End If
 
    Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, "请选择文件夹", _
                                            BIF_RETURNONLYFSDIRS)
    If Not shlFolder Is Nothing Then
        txtFilePath.Text = shlFolder.Items.Item.Path
    End If
End Sub 

你可能感兴趣的:(VB选择文件夹代码)