假设在一个叫AAA的目录中有一个叫BBB的目录
我的工程文件在AAA目录中,在BBB目录中有一个Notepad.exe
现在工程的窗体中一个按钮的click事件中有如下代码:Dim RetVal
RetVal = Shell("..\BBB\notepad.exe", 1)运行时找不到文件,请指出错误。望得到大家的帮助,谢谢!

解决方案 »

  1.   

    '方法是用,但是可能麻烦了点,关注其它简单方法
    '引用Microsoft Scripting RuntimeDim Fso As New FileSystemObject
    Dim Fd As Folder
    Set Fd = Fso.GetFolder(App.Path)
    Shell Fd.ParentFolder.Path & "\BBB\notepad.exe", vbNormalFocus
      

  2.   

    这样行吧:
    dim currentPath as string
    currentPath=IIf(Right(App.Path, 1) = "\", Left(App.Path, Len(App.Path) - 1), App.Path)
    RetVal = Shell(currentPath & "\BBB\notepad.exe", 1)
      

  3.   

    字符串处理方法可就多了
    1.
    Shell Mid(App.Path, 1, InStrRev(App.Path, "\")) & "\BBB\notepad.exe", 1
    2.
    Dim Paths() As String
    Paths = Split(App.Path, "\")
    ReDim Preserve Paths(UBound(Paths) - 1)
    Shell Join(Paths, "\")) & "\BBB\notepad.exe", 1
    ......
    ^_^