'光看文字也许不知道我在说什么,简单笔画一下。 Private Sub Command1_Click() Dim mScript As New CScript list.additem "你好" call mScript.comout ("all") ... ... msgbox "结束" end sub '类模块代码 Public Function comout(ByVal com As String) As String if com="all" then msgbox "完成" else msgbox "失败" [exit sub] '我就是想完成这句的功能,但是我这个是报错的! '我想到这里的话这个程序停止,但不是退出 end Function
不明白楼主想表达什么…… 1.貌似也不是挂起进程 2.在public function中用exit sub肯定是错的,只能exit function 3.在msgbox的时候就已经挂起,程序也暂停了 4.如果是要判断返回值,你就应该public function xxx as boolean,然后在主程序判断
Public Function comout(ByVal com As String) As String if com="all" then 'msgbox "完成" comout="OK" else 'msgbox "失败" comout="FAIL" end if end FunctionPrivate Sub Command1_Click() Dim mScript As New CScript list.additem "你好" if mScript.comout ("all")="OK" then '正确,继续执行接下来的代码 else '不正确,执行提示错误之类的代码 msgbox "XXXXXX" exit sub end if ... ... msgbox "结束" end sub直接使用返回值不就行了么.另外,代码加缩进是个好习惯,按TAB键.
这样不行,如果没有好的办法,我只能加end关闭程序了。
Private Sub Command1_Click() Dim mScript As New CScript If mScript.comout("all") = False Then MsgBox "错误" Unload Me End If End Sub '类模块代码 Public Function comout(ByVal com As String) As Boolean …… …… If com <> "xxx" Then Exit Function '你的脚本代码 …… …… comout = True End Function
'光看文字也许不知道我在说什么,简单笔画一下。
Private Sub Command1_Click()
Dim mScript As New CScript
list.additem "你好"
call mScript.comout ("all")
...
...
msgbox "结束"
end sub
'类模块代码
Public Function comout(ByVal com As String) As String
if com="all" then
msgbox "完成"
else
msgbox "失败"
[exit sub] '我就是想完成这句的功能,但是我这个是报错的!
'我想到这里的话这个程序停止,但不是退出
end Function
或者说弄一个按钮,点击将可以终止正在运行的程序。
就好比exit sub能让过程停止。只是现在我要这个exit sub不是在运行的那个过程中
而是在另一个过程中的、
能实现吗,只要是我描述的功能就行了
1.貌似也不是挂起进程
2.在public function中用exit sub肯定是错的,只能exit function
3.在msgbox的时候就已经挂起,程序也暂停了
4.如果是要判断返回值,你就应该public function xxx as boolean,然后在主程序判断
if com="all" then
'msgbox "完成"
comout="OK"
else
'msgbox "失败"
comout="FAIL"
end if
end FunctionPrivate Sub Command1_Click()
Dim mScript As New CScript
list.additem "你好"
if mScript.comout ("all")="OK" then
'正确,继续执行接下来的代码
else
'不正确,执行提示错误之类的代码
msgbox "XXXXXX"
exit sub
end if
...
...
msgbox "结束"
end sub直接使用返回值不就行了么.另外,代码加缩进是个好习惯,按TAB键.
Dim mScript As New CScript
If mScript.comout("all") = False Then
MsgBox "错误"
Unload Me
End If
End Sub
'类模块代码
Public Function comout(ByVal com As String) As Boolean
……
……
If com <> "xxx" Then Exit Function
'你的脚本代码
……
……
comout = True
End Function
但是发现script_control.后面没有成员出来。
我就在想Set script_control = CreateObject("MSScriptControl.ScriptControl")
与拖控件的区别了