vb文件夹路径|请教vb6中如何选择文件夹路径

vb文件夹路径|请教vb6中如何选择文件夹路径的第1张示图

❶ vb 完整路径获取文件夹路径

Path = "c:\soft\中国人\setup.exe"For i = 1 To Len(Path)If Mid(Path, i, 1) = "\" Then Print Left(Path, i)Next i 或者:Path = "c:\soft\中国人\setup.exe"For i = 1 To Len(Path)If Mid(Path, i, 1) = "\" Then Text1.Text = Left(Path, i)Next i将路径存回放于答text1内

❷ VB获取文件路径

VB2008测试通过 Imports System Imports System.IO Imports System.Threading Imports System.Windows.Forms Public Class FrmMainDim newSearcher As getFileByName Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loadrball.Checked = Truetbpath.Text = ""tbpath.Enabled = Falsebtndlg.Enabled = FalseEnd Sub Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Clicktv.Nodes.Clear()btnOK.Enabled = FalsebtnExit.Enabled = FalseIf rball.Checked Thenrun()ElseIf tbpath.Text = "" ThenMsgBox("请输入或者选择一个路径")Exit SubElserun(tbpath.Text)End IfEnd IfEnd Sub Private Sub btndlg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndlg.Clickfbdlg.RootFolder = Environment.SpecialFolder.MyComputerfbdlg.ShowDialog()tbpath.Text = fbdlg.SelectedPathEnd Sub Private Sub rbchs_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbchs.CheckedChangedIf rbchs.Checked = True Thentbpath.Enabled = Truebtndlg.Enabled = TrueElsetbpath.Enabled = Falsebtndlg.Enabled = FalseEnd IfEnd Sub Private Sub run()If tbfileName.Text = "" ThenMsgBox("请输入文件名称")btnOK.Enabled = TruebtnExit.Enabled = TrueExit SubElsenewSearcher = New getFileByName(tbfileName.Text)newSearcher.GetDrivers()tmr.Enabled = Truetmr.Interval = 10End IfEnd Sub Private Sub run(ByVal path As String)If tbfileName.Text = "" ThenMsgBox("请输入文件名称")btnOK.Enabled = TruebtnExit.Enabled = TrueExit SubElsenewSearcher = New getFileByName(tbfileName.Text)newSearcher.SearchFolder(path)tmr.Enabled = Truetmr.Interval = 50End IfEnd Sub Private Sub tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.TickLblshow.Text = newSearcher.currentPathIf newSearcher.cntThread = 0 And newSearcher.isDone Then'MsgBox(newSearcher.getFile.ToString)'MsgBox("全部线程结束")For Each Str As String In newSearcher.getFiletv.Nodes.Add(Str)Next'For i As Integer = 0 To newSearcher.getFile.Length – 1'tv.Nodes.Add(newSearcher.getFile(i))'Nexttmr.Enabled = FalsebtnExit.Enabled = TruebtnOK.Enabled = TrueEnd IfMy.Application.DoEvents()End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.ClickMe.Close()End Sub End Class

❸ VB查找指定文件夹并获取文件路径的代码

1.首先打开来Excel电子表格,然自后在开发工具中打开VBA编辑器,如下图。

❹ VB的什么控件是可以选择文件夹路径

commondialogmiscrosoft common dialog 6.0showopen 打开showsave 保存属性filename 所选的文件路径

❺ vb 如何通过一个文件的全路径获得该文件所在文件夹

'编写函数,获取PrivateFunctionGetLuJIn(ByValaAsString)AsStringDimiAsLongFori=Len(a)To1Step-1Ifmid(a,i,1)=""Then'获取最后一个""位置GetLuJin=Left(a,i-1)'函数返回最后一个""前面的东西ExitFunction'获取之后,函数没专什么事了,退出属EndifNextiEndFunction

❻ VB获取文件路径与名称

在VB中可以用Command函数获得传递过来的命令行参数,比如:Private Sub Form_Load() MsgBox CommandEnd Sub

❼ vb获取启动文件夹路径

工程/引用/Windows Script …..Dim wsh As New WshShellMsgBox wsh.SpecialFolders("Startup")

❽ VB 浏览文件夹获取文件夹路径

这个是我用VB做的文件选择器,仿Linux的资源浏览器!

❾ 请教vb6中如何选择文件夹路径

'在主窗体中,加入以下代码OptionExplicitPrivateSubForm_Load()Me.Caption=C_SelectPath(Me.hwnd,App.Path)'选择文件夹路径EndSub'========================================================================'在模块中加入下面的代码OptionExplicitPrivatemSetPathAsStringPrivateTypeBrowseInfohWndOwnerAsLongpIDLRootAsLongpszDisplayNameAsLonglpszTitleAsStringulFlagsAsLonglpfnCallbackAsLonglParamAsLongiImageAsLongEndTypePrivateConstMAX_PATH=512&PrivateConstBFFM_INITIALIZED=1&PrivateConstBFFM_SELCHANGED=2&PrivateConstWM_USER=&H400PrivateConstBFFM_SETSTATUSTEXT=(WM_USER+100)PrivateConstBFFM_SETSELECTION=(WM_USER+102)PrivateConstWM_SETTEXT=&HCPrivateConstBIF_RETURNONLYFSDIRS=1"ole32.dll"(ByValhMemAsLong)"shell32"(lpBIAsBrowseInfo)AsLong"shell32.dll"Alias"SHGetPathFromIDListA"(ByValpidlAsLong,ByValpszPathAsString)AsLong"user32.dll"Alias"SendMessageA"(ByValhwndAsLong,ByValwMsgAsLong,ByValwParamAsLong,lParamAsAny)AsLong"user32"Alias"SendMessageW"(ByValhwndAsLong,ByValwMsgAsLong,ByValwParamAsLong,ByVallParamAsLong)AsLong"user32"Alias"FindWindowExA"(ByValhWnd1AsLong,ByValhWnd2AsLong,ByVallpsz1AsString,ByVallpsz2AsString)AsLong(AddAsLong)AsLongGetAddressofFunction=AddEndFunction(ByValhwndAsLong,ByValuMsgAsLong,ByVallParamAsLong,ByVallpDataAsLong)AsLongDimlpIDListAsLongDimlRetAsLongDimsBufferAsStringDimFhwndAsLongDimszPath()AsByteOnErrorGoToerrhandlerSelectCaseuMsgCaseBFFM_INITIALIZEDCallSendMessage(hwnd,BFFM_SETSELECTION,True,ByValmSetPath)'传递默认路径Fhwnd=FindWindowEx(hwnd,0,"Edit",vbNullString)CallSendMessage(Fhwnd,WM_SETTEXT,0,ByValmSetPath)CaseBFFM_SELCHANGED''路径变化sBuffer=Space(MAX_PATH)lRet=SHGetPathFromIDList(lParam,ByValsBuffer)CoTaskMemFreelpIDListIflRet=1ThenCallSendMessage(hwnd,BFFM_SETSTATUSTEXT,0,sBuffer)'改变对话框的状态信息Fhwnd=FindWindowEx(hwnd,0,"Edit",vbNullString)szPath=sBufferCallSendMessageLong(Fhwnd,WM_SETTEXT,0,VarPtr(szPath(0)))EndIfEndSelecterrhandler:BrowseCallbackProc=0EndFunction'使用方法:'Me.Caption=C_SelectPath(Me.hwnd,App.Path)'选择文件夹路径PublicFunctionC_SelectPath(m_hwmd&,strPathAsString)AsStringDimlpIDListAsLongDimudtBIAsBrowseInfoWithudtBI'初试化udtBI结构mSetPath=strPath'设置默认路径.hWndOwner=m_hwmd.ulFlags=BIF_RETURNONLYFSDIRSOr&H10Or&H40'&H10=路径框&H40=新建文件夹.lpszTitle="请选择文件夹:".lpfnCallback=GetAddressofFunction(AddressOfBrowseCallbackProc)'getaddressoffunction.EndWithlpIDList=SHBrowseForFolder(udtBI)'弹出文件夹查看窗口IflpIDListThenDimsPathAsString,retAsLongsPath=String$(MAX_PATH,0)ret=SHGetPathFromIDList(ByVallpIDList,ByValsPath)CallCoTaskMemFree(lpIDList)IfretThenC_SelectPath=Replace(sPath,Chr(0),"")EndIfEndIfEndFunction

❿ VB获取文件夹路径

用API遍历当前桌面已打开的子窗口,获得窗口句柄和ID,然后通过ID获得该文件夹的路径,总之一句话,你要实现的功能VB无法做到,API可以

未经允许不得转载:山九号 » vb文件夹路径|请教vb6中如何选择文件夹路径

赞 (0)