vb怎么用选择文件夹窗口获得文件夹路径

代码如下:PrivateTypeBrowseInfohWndOwnerAsLongpIDLRootAsLongameAsLonglpszTitleAsLongulFlag... 代码如下:

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
ame As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = 1
Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
————————————————————————————————
Private Sub Command4_Click()
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo

With udtBI
'Set the owner window
.hWndOwner = Me.hWnd
'lstrcat appends the two strings and returns the memory address
.lpszTitle = lstrcat("请选择文件夹", "") '标题
'Return only if the user selected a directory
.ulFlags = BIF_RETURNONLYFSDIRS
End With

'Show the 'Browse for folder' dialog
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
'Get the path from the IDList
SHGetPathFromIDList lpIDList, sPath
'free the block of memory
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If

MsgBox sPath

End Sub

请问代码应该怎么改?
vb怎么用选择文件夹窗口获得文件夹路径
把获得的文件夹路径显示在Text1

我的意思就是“文件夹选择窗口”选择的文件夹,的路径。这个代码只是用msgbox 显示文件夹路径,我是想把文件夹路径显示在打开“文件夹选择窗口”的窗口里的Text1那里。
展开
 我来答
若以下回答无法解决问题,邀请你更新回答
zUfs6652
2008-11-09 · TA获得超过4217个赞
知道小有建树答主
回答量:1431
采纳率:0%
帮助的人:1272万
展开全部
代码正确`不明白你想表达什么思想
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式