OptionExplicit PrivateSub Command1_Click() OnErrorGoTo ErrLabel '打开错误陷阱 '------------------------------------------------ Dim a AsBoolean a =True If getresult =FalseAnd1<0Then MsgBox a Else MsgBox a EndIf '------------------------------------------------ ExitSub '---------------- ErrLabel: '跳出错误对话框,并保存错误信息 ResumeNext End Sub PrivateFunction getresult() AsBoolean Err.Raise 100 End Function