就是有一个打开按扭按了之后可以选择想打开的文件
谢谢

解决方案 »

  1.   

    我看到一个例子,但是总是有错误,不知道是哪里有问题,能不能帮我看一下?
    使用Common Dialog Control控件
    然后加了一个按扭
    Private Sub Form_Load()
      Dialog.InitDir="C:\Windows"
      Dialog.Filter="文本文件(*.exe)|*.txt|所有文件(*.*)|*.*"
      Dialog.FilterIndex=1
    End Sub
    Private Sub cmd1_Click()
       Dialog.Action=1
       pathname="C:\Windows\notepad.exe"&""&Dialog.FileName
       Re=Shell(pathname,1)
    End Sub
      

  2.   

    pathname="C:\Windows\notepad.exe"&""&Dialog.FileName
    -------------------------------------------------------
    pathname="C:\Windows\notepad.exe " & Dialog.FileName
    注意,notepad.exe后面有一个空格
      

  3.   

    谢谢!可是调试的时候说Dialog.InitDir="C:\Windows"有错误
      

  4.   

    可是调试的时候说Dialog.InitDir="C:\Windows"有错误
    ------------------------------------------------你是在2000下调试的?2000下的系统目录是c:\winnt,你这样用当然不对了
      

  5.   

    我是在xp下调试的
    谢谢!
    我还有一个问题,这个可不可以用文件系统来实现,就是用一个驱动器列表框,一个目录列表框一个文件列表框和一个组合框一起来实现.
    Option Explicit
    Private Sub ComboType_Click()
    File1.Pattern = Mid(ComboType.texxt, 21)
    End Sub
    Private Sub Dir1_Change()
    File.Path = Dir1.Path
    End Sub
    Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    End Sub
    Private Sub File1_Click()
    Magbox File1.FileName
    End Sub
    Private Sub File1_DblClick()
    CdDir Dir1.Path
    Retval = Shell(File1.FileName, 1)
    End Sub
    Private Sub Form_Load()
    Dim item As String
    item = "所有文件(*.*)"
    ComboType.AddItem item + Space(20 - Len(item)) + "*.*"
    ~~~~~~~~~~说这里变量未定义
    item = "可执行文件(*.exe)"
    ComboType.AddItem item + Space(20 - Len(item)) + "*.exe"
    ComboType.ListIndex = 0
    End Sub