错误处理程序中的错误处理 [英] Error handling in Error handler

查看:132
本文介绍了错误处理程序中的错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下面的代码,当用户单击输入框中的取消按钮时,错误正在由错误处理程序处理。

I am using below code, When user click on cancel button in the input box, the error is being handled by the error handler.

但是如果有错误再次在错误处理程序中使用该错误处理程序。

But if there is error again in the error handler then that error is not getting handled by the error handler.

Sub calculateroot()

    Dim msg As String, t as Integer
    On Error GoTo myhandle
    Dim inp As Integer, sql As Single
    inp = InputBox("Enter the number to find the square root")
    sql = Sqr(inp)
    Exit Sub
myhandle:
  t = InputBox("Is this recursive ?")
End Sub

我应该对代码进行哪些更改以处理在错误处理程序中生成的错误?

What changes should I make in the code to handle the error generated in error handler ?

推荐答案

您必须重置错误处理程序,然后设置一个新的错误处理程序:

You have to reset the error handler and then set a new one:

Sub calculateroot()

    Dim msg As String, t As Integer
    On Error GoTo myhandle
    Dim inp As Integer, sql As Single
    inp = inputbox("Enter the number to find the square root")
    sql = Sqr(inp)
    Exit Sub
myhandle:
    On Error GoTo -1
    On Error GoTo myhandle2
    t = inputbox("Is this recursive ?")
     MsgBox t
    Exit Sub
myhandle2:
    MsgBox "myhandle2"
End Sub

这篇关于错误处理程序中的错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆