代码如下:
  Dim strPath As String
  Dim a As String
  a = "C:\00\B\A"
  strPath = "..\" + a + "/notepad.exe"
  Shell strPath, 1notepad.exe位置:C:\00\B\notepad.exe
我不想通过InstrB等方式将字符串a进行拆分这样的操作。
我像通过“..\”来表示相对路径,请问上面代码如何修改?

解决方案 »

  1.   


    dim strfile as string
    dim strPath as string strfile="..\notepad.exe"
    strpath=Replace(strfile,"..\",app.path & "\")
      

  2.   

    楼上的代码,用楼主的例子都是通不过的."C:\00\B\A"看了,不明白楼主的意思.你都给出绝对路径了,还弄../做什么,这个"../"是asp.net里面的
      

  3.   

    1楼../是要返回上一级的。
    但通过replace直接就将../替换掉了,返回不到上一级目录。
      

  4.   

    Dim strPath As String
    Dim a As String
    a = "C:\00\B\A"
    strPath = a & "\..\notepad.exe"
    Shell strPath, vbNormalFocus
    1)相当路径可以直接拼上去用。
    2)路径分割符是 "\" 而不是  "/"。
    3)连接字符串用 & 而不是 +
    4)不要用魔术数。