代码如下:
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进行拆分这样的操作。
我像通过“..\”来表示相对路径,请问上面代码如何修改?
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进行拆分这样的操作。
我像通过“..\”来表示相对路径,请问上面代码如何修改?
dim strfile as string
dim strPath as string strfile="..\notepad.exe"
strpath=Replace(strfile,"..\",app.path & "\")
但通过replace直接就将../替换掉了,返回不到上一级目录。
Dim a As String
a = "C:\00\B\A"
strPath = a & "\..\notepad.exe"
Shell strPath, vbNormalFocus
1)相当路径可以直接拼上去用。
2)路径分割符是 "\" 而不是 "/"。
3)连接字符串用 & 而不是 +
4)不要用魔术数。