“on error goto”或“尝试捕获” [英] "on error goto" or "try catch"

查看:90
本文介绍了“on error goto”或“尝试捕获”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




作为一名前VB程序员,我习惯了on error goto-errorhandling。我实际上所有的VB.NET样本都可以看到,人们可以使用尝试 -

catch - 错误处理。

两者中哪一个最好?是否有充分的理由使用Try-Catch?

请问on error goto将来消失?使用trey-catch有什么合理的理由吗?编程是更好吗?等等:-)


我对on error goto更加舒服,主要是因为我使用了

给它我猜。任何有关此主题的帮助或反馈都会很好!


提前致谢!

Hi,

As a former VB-programmer I''m used to the "on error goto"-errorhandling. I
see that in actually all the VB.NET-samples I can fin people use the "Try -
catch"-errorhandling.

Which of the two is the best? Are there good reasons to use the Try-Catch?
Will the "on error goto" disapear in the future? Are there any logical
reasons to use trey-catch? Is it ''better'' programming? etc etc :-)

I''m jsut more comfortable with the "on error goto", mostly because I''m used
to it I guess. Any help or reflectiosn regarding this subject would be nice!

Thanks in advance!

推荐答案

Hi Dragu ,


如果你习惯了


的可能性尝试

Catch(倍数

结束尝试

最后


从那个嵌套的可能性,你不相信你能做到

它使用on error goto


我希望这能给出一个想法吗?


Cor
Hi Dragu,

If you are used to the possibilties from the

Try
Catch (multiples
End Try
Finally

And the nesting posibilities from that, you would not believe you could do
it with the "on error goto"

I hope this gives an idea?

Cor
作为一个以前的VB程序员我已经习惯了on error goto-errorhandling。我看到实际上所有的VB.NET样本我都可以使用
< Try - 抓住-errorhandling。

两者中哪一个是最好的?是否有充分的理由使用Try-Catch?
将来,on error goto是否会消失?有没有合理的理由使用trey-catch?它是''更好''p rogramming?等等:-)

我对on error goto更加舒服,主要是因为我猜它是我用的b $ b。关于这个主题的任何帮助或反馈将是
很好!
As a former VB-programmer I''m used to the "on error goto"-errorhandling. I
see that in actually all the VB.NET-samples I can fin people use the "Try - catch"-errorhandling.

Which of the two is the best? Are there good reasons to use the Try-Catch?
Will the "on error goto" disapear in the future? Are there any logical
reasons to use trey-catch? Is it ''better'' programming? etc etc :-)

I''m jsut more comfortable with the "on error goto", mostly because I''m used to it I guess. Any help or reflectiosn regarding this subject would be nice!





我是VB程序员和我习惯了但是现在试试..抓住是

更好。

通过这个声明你可以捕捉所有不同类型的例外和

为每个人执行特定的操作。

我希望这对你有用

问候

Valeria


" DraguVaso" < PI ********** @ hotmail.com> ha scritto nel messaggio

news:3f ********************** @ reader0.news.skynet。是...
Hi,
I was a VB-programmer to and I was used to on error but now Try .. catch is
better.
With this statement you can catch all different types of exceptions and
perform a specific action for each one.
I hope this will be usefull for you
Regards
Valeria

"DraguVaso" <pi**********@hotmail.com> ha scritto nel messaggio
news:3f**********************@reader0.news.skynet. be...


作为一名前VB程序员,我习惯了on error goto-errorhandling。我看到实际上所有的VB.NET样本我可以使用
尝试 - 捕获 - 错误处理。

两者中哪一个是最好的?有没有充分的理由使用Try-Catch?
请问on error goto将来消失?有没有合理的理由使用trey-catch?编程是更好吗?等等:-)

我对on error goto更加舒服,主要是因为我猜它是我用的b $ b。任何关于这个主题的帮助或反馈都是
很好!
提前致谢!
Hi,

As a former VB-programmer I''m used to the "on error goto"-errorhandling. I
see that in actually all the VB.NET-samples I can fin people use the "Try - catch"-errorhandling.

Which of the two is the best? Are there good reasons to use the Try-Catch?
Will the "on error goto" disapear in the future? Are there any logical
reasons to use trey-catch? Is it ''better'' programming? etc etc :-)

I''m jsut more comfortable with the "on error goto", mostly because I''m used to it I guess. Any help or reflectiosn regarding this subject would be nice!
Thanks in advance!



*Valeria ; < VA *** @ tiscali.it> scripsit:
* "Valeria" <va***@tiscali.it> scripsit:
我是一个VB程序员,我习惯了但是现在试试.. catch更好。
I was a VB-programmer to and I was used to on error but now Try .. catch is
better.




但是:_为什么它更好?在某些情况下,IMO会更好,因为它会使代码更加紧凑,但有时,例如在强制执行一个大型算法时,它会非常烦人,因为它会阻止读者看到代码的含义。


只是想一想。


- -

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>



But: _Why_ exactly is it better? It''s IMO better in some cases because it
leaves code more compact, but sometimes, for example when impementing a
large algorithm, it''s very annoying because it will prevent the reader
from seeing the point of the code.

Just a thought.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


这篇关于“on error goto”或“尝试捕获”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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