VB 如何打开相对目录文件

来源:百度知道 编辑:UC知道 时间:2024/09/19 20:04:54
我要点击Command1打开同文件夹下Shell.exe文件

不用路径,就是同文件夹的文件,如:open "shell.exe" for binary as #1,而用app.path则容易出错!

Shell app.path & "\Shell.exe", vbNormalFocus

上面的如果在根目录(如:D:\)下就会出错,这样写万无一失。
代码如下。
============
Private Sub Command1_Click()
Shell IIf(Len(App.Path) > 3, App.Path & "\", App.Path) & "shell.exe"
End Sub

Private Sub Command1_Click()
Shell App.Path & "\shell.exe", 1
End Sub

Private Sub Command1_Click()
Shell App.Path & "/shell.exe", vbNormalFocus
End Sub

Private Sub Command1_Click()
Shell "shell.exe
End Sub
最简单