7,763
社区成员
发帖
与我相关
我的任务
分享
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
Public Function comout(ByVal com As String) As String
if com="all" then
'msgbox "完成"
comout="OK"
else
'msgbox "失败"
comout="FAIL"
end if
end Function
Private 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键.
'光看文字也许不知道我在说什么,简单笔画一下。
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