首页 | 文章中心 | 下载中心 | 本站特供 | 软硬件结合论坛 | 
您现在的位置: 中国软硬件结合技术网 >> 文章中心 >> 软件技术 >> VB、JAVA等 >> 正文 用户登录 新用户注册
[推荐]vb中在文本框里显示选中的文件夹路径            【字体:
vb中在文本框里显示选中的文件夹路径
作者:佚名    文章来源:网络    点击数:    更新时间:2007-8-11
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
sFoldersPath = y.Title
Do Until y.ParentFolder Is Nothing
sFoldersPath = y.ParentFolder & "\" & sFoldersPath
If VBA.InStr(sPath, ":") = 0 Then
If Not y.ParentFolder Like "*:*" Then
sPath = y.ParentFolder & "\" & sPath
Else
sPath = VBA.Mid(y.ParentFolder, VBA.InStr(y.ParentFolder, ":") - 1, 2) & "\" & sPath
'Exit Do
End If
End If
Set y = y.ParentFolder
Loop
If VBA.Len(VBA.Trim(sPath)) > 0 Then
text1.text= sPath & vbCrLf
End If
End If
End Sub
文章录入:woshi    责任编辑:Polylove 
  • 上一篇文章: VB实现图形动画的三种方法

  • 下一篇文章: 使用vbscript的字符串操作函数处理文本
  • 发表评论】【告诉好友】【打印此文】【关闭窗口
          最新热点       最新推荐       相关文章
    没有相关文章
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)