教主的小说:vb问题,不会

来源:百度文库 编辑:高校问答 时间:2024/05/05 10:52:19
Private Sub Command5_Click()
End
End Sub
Private Sub Command6_Click()
CommonDialog1.CancelError = True
On Error GoTo Cancel
CommonDialog1.Filter = _
"(可执行文件*.exe)*.exe|*.exe|(可执行文件*.com)*.com|*.com"
CommonDialog1.FilterIndex = 0
CommonDialog1.Action = 1
Shell CommonDialog1.FileName, 1
Cancel:
End Sub
就是这样
Shell CommonDialog1.FileName, 1
后面那个1是什么意思,请详细解释
没看明白,请说的详细些,谢谢

Shell [String for Filename] [Integer for ShellStatus]
最后这个Parameter - 也就是你说的1
是指定程序运行的状态。可以是数字,也可以用以下VB Countent替代。你一看就明白了。
vbHide
vbMaximizedFocus
vbMinimizedFocus
vbMinimizedNoFocus
vbNormalFocus
vbNormalNoFocus

以下是个例子:
' Start the program.
Private Sub cmdRun_Click()
On Error GoTo ShellError

Select Case cboShellStyle.Text
Case "vbHide"
Shell txtProgram.Text, vbHide
Case "vbMaximizedFocus"
Shell txtProgram.Text, vbMaximizedFocus
Case "vbMinimizedFocus"
Shell txtProgram.Text, vbMinimizedFocus
Case "vbMinimizedNoFocus"
Shell txtProgram.Text, vbMinimizedNoFocus
Case "vbNormalFocus"
Shell txtProgram.Text, vbNormalFocus
Case "vbNormalNoFocus"
Shell txtProgram.Text, vbNormalNoFocus
End Select
Exit Sub

ShellError:
MsgBox "Error Shelling file." & vbCrLf & _
Err.Description, vbOKOnly Or vbExclamation, _
"Error"
Exit Sub
End Sub

1是确定
0是否定

Shell函数的作用是在VB中调用一个可执行文件,返回一个 Variant(Double),如果成功调用的话,该值代表这个程序的任务标识ID,若不成功,则会返回 0。
Shell函数的格式为:
Shell(pathname[,windowstyle])
显然,语句[Shell CommonDialog1.FileName, 1]中的1就指windowstyle啦