静态变量路径 用shell打开 CommonDialog控件指定的exe路径
求vb代码
vb shell函数 与 CommonDialog 应用
答案:2 悬赏:30
解决时间 2021-03-05 11:04
- 提问者网友:放荡不羁
- 2021-03-05 00:34
最佳答案
- 二级知识专家网友:陪我到地狱流浪
- 2021-03-05 01:43
' 窗口中画1个文本框、1个通用对话框控件、两个按钮
Private Sub Command1_Click()
' 打开文件
CommonDialog1.DialogTitle = "打开可执行程序"
CommonDialog1.Flags = &H4
CommonDialog1.Filter = "可执行程序(*.exe)|*.exe"
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
' 用 Shell( )执行程序
Dim sExeFile As String
sExeFile = Text1.Text
If (LCase$(Right$(sExeFile, 4)) <> ".exe") Then
MsgBox "Text1中指定的文件不是可执行程序。", 32
Exit Sub
End If
If (Dir$(sExeFile, 7) = "") Then
MsgBox "找不到指定的文件。", 32
Exit Sub
End If
Call Shell(sExeFile, vbNormalFocus)
End Sub
Private Sub Command1_Click()
' 打开文件
CommonDialog1.DialogTitle = "打开可执行程序"
CommonDialog1.Flags = &H4
CommonDialog1.Filter = "可执行程序(*.exe)|*.exe"
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub
Private Sub Command2_Click()
' 用 Shell( )执行程序
Dim sExeFile As String
sExeFile = Text1.Text
If (LCase$(Right$(sExeFile, 4)) <> ".exe") Then
MsgBox "Text1中指定的文件不是可执行程序。", 32
Exit Sub
End If
If (Dir$(sExeFile, 7) = "") Then
MsgBox "找不到指定的文件。", 32
Exit Sub
End If
Call Shell(sExeFile, vbNormalFocus)
End Sub
全部回答
- 1楼网友:疯山鬼
- 2021-03-05 02:46
你好!
commondialog.showopen
if commondilog.filename="" then goto err
shell commondialog.diletitle
:err
end
仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯