Sub showerror ()
Dim s As String
Dim crlf As String
crlf = Chr(13) + Chr(10)
s = "运行时发生下列错误:" + crlf
注释:add the error string
s = s + Error$ + crlf
注释:add the error number
s = s + "错误码为: " + CStr(Err)
Beep 注释:beep and show the error
X= MsgBox (s,2)
End Sub
调用例子:
sub abc()
onerror goto 1’发生错误时转到 1
.
.
程序体
.
.
exit sub
1
showerror
if err=… then
.
.
错误处理部分
.
.
endif
exit sub
end sub








