vb中在文本框里显示选中的文件夹路径
来源:百度知道 编辑:UC知道 时间:2024/05/10 04:47:55
Private Sub Command1_Click()
'引用 Microsoft Shell Controls And Automation
Const BIF_EDITBOX = &H10
Const BIF_STATUSTEXT = &H4
Const BIF_RETURNFSANCESTORS = &H8
Const BIF_VALIDATE = &H20
Const BIF_BROWSEFORCOMPUTER = &H1000
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_DONTGOBELOWDOMAIN = 2
Dim x As New Shell32.Shell
Dim y As Shell32.Folder
Set y = x.BrowseForFolder(Me.hWnd, "aa", 1)
'法1:
If Not y Is Nothing Then
MsgBox y.ParentFolder.ParseName(y.Title).Path
End If
'====================================
'法2:
If Not y Is Nothing Then
Dim sFoldersPath As String
Dim sPath As String
sPath = y.Title
sFold