关于ON ERROR和TRY ... CATCH的问题 [英] Questions about ON ERROR and TRY...CATCH

查看:102
本文介绍了关于ON ERROR和TRY ... CATCH的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)如何使用ON ERROR GOTO -1?我不理解帮助文字.

1) How is ON ERROR GOTO -1 used? I don't understand the help text.

2)似乎不赞成ON ERROR.对于ON ERROR RESUME NEXT,建议使用Try ... Catch替代品. IE.我有一系列命令,其中任何一个命令都可能引发异常,并且我想忽略所有异常,但尝试每条命令?

2) ON ERROR seems to be deprecated. What is the recommended Try...Catch replacement for ON ERROR RESUME NEXT. ie. where I have a series of commands, any of which may throw an exception, and I want to ignore all exceptions yet attempt every command?

推荐答案

1.不要再使用它了,因为它仍然在Basic中,它仍然在VB中

1. Don't use it anymore it is still in VB because it was in Basic

2. ON ERROR RESUME NEXT等同于他甚至正在使用On Error Resume Next".在他的程序中

2. ON ERROR RESUME NEXT is an equivalent for "he is even using On Error Resume Next" in his programs

您可以不做任何事情而进行捕捉,它具有相同的功能.

You can to do it with catching without doing something, it has the same equivalent.

尝试
   AmmountToPay =  AmmountToPay/AValue
渔获
结束捕捉

Try
   AmmountToPay =  AmmountToPay / AValue
Catch
End Catch

如果AValue = 0,这是AmmountToPay可能很高的情况之一,但由于程序恢复,它将被支付.

This is one of the situations where AmmountToPay is probably to high if AValue = zero, but it will be paid because the program resumes.

有人可能会在此示例中为该程序错误付费,这是使用该示例的示例,但是还有很多似乎还不错的示例,但实际上在以后的某个地方给出了错误.

Somebody will probably pay in this sample for this program error, this is a sample where it is used, but there are many more which seems not so bad, but in fact give the error somewhere later.

应该始终识别出一个错误.

An error should always be recognizable be hanlded.

 

 

 

 

 


这篇关于关于ON ERROR和TRY ... CATCH的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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