像点击文件夹“浏览”按钮后,弹出浏览对话框,浏览确定后返回原来的对话框并得到的路径值返回到TextBox.text且刷新。下面在问号一行为什么出错。请大虾指点Public bbbpath As mainwindow
Private Sub Dir1_Change()
    VBakPath = Dir1.Path
  ?  Set bbbpath.BakPath.Text = VBakPath
end sub

解决方案 »

  1.   

    dim bbbpath As new mainwindow
    Private Sub Dir1_Change()
        VBakPath = Dir1.Path
        bbbpath.BakPath.Text = VBakPath
    end sub
      

  2.   


        去掉set。
      

  3.   

    yoki(小马哥--鬓微霜,又何妨) 
    去掉Set也不行,提示Object variable or With block variable not set
      

  4.   

    set是针对对象用的,BakPath.Text 是个字串,所以用set是错误的:)
      

  5.   

    bbbpath.BakPath.Text = VBakPath
    中的bbbpath是mainwindow窗体的,不在同本窗体内
      

  6.   

    你这样做太麻烦了,而且用dirlistbox界面也不美观,建议这样://像点击文件夹“浏览”按钮后,弹出浏览对话框,浏览确定后返回原来的对话框并得到的路径值返回到TextBox.text
    '一个窗体即可
    '一个按钮一个textbox
    Private Sub Command1_Click()
        Dim myShell As Object
        Set myShell = CreateObject("Shell.Application")
        Dim s As String
        Dim mfolder As Object
        '调用系统的浏览文件夹对话框
        Set mfolder = myShell.BrowseForFolder(Me.hWnd, "请选择文件夹", 1)
        If Not mfolder Is Nothing Then
            s = mfolder.Self.Path
            Text1.Text = s
        End If
        Set mfolder = Nothing
        Set myShell = Nothing
    End Sub
    当然上述过程用api实现也可,用api实现的代码网上有很多,我就不写了:)
      

  7.   

    rainstormmaster(暴风雨 v2.0) 
    太感谢了!!!