By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

on error against try..catch

P: n/a
I have converted a large vb6 program with an add-in that for every routine
gimme
the error handling:
the add-in adds one line on the head of the routine
"if myerrhandle then ON ERROR GOTO HERRHANDLER"
and the herrhandler label at the botton where i write in a logfile the name
of the routine, the errors and other information
Well setting myerrhandle to true seems that the error handling keeps on
working in
..net is it right? what's the difference from exception handling?
if exception handling is better like i think how can i do to pass from
errhandling to excection handling?
Some times i use on error resume next has got
handling exception an equivalent?
Thasnks
Best Regards
DavideR
Jan 11 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Yes, this is included for legacy. Actually the underyling MSIL code for on
error uses Try/Catch...

Try :
http://msdn.microsoft.com/library/de...Statements.asp

You are allowed to do nothing when an exception is raised but I would still
double check that I can't do otherwise (bascially it should IMO never be
done, what is your scenario ?).

--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4B**********************************@microsof t.com...
I have converted a large vb6 program with an add-in that for every routine
gimme
the error handling:
the add-in adds one line on the head of the routine
"if myerrhandle then ON ERROR GOTO HERRHANDLER"
and the herrhandler label at the botton where i write in a logfile the name of the routine, the errors and other information
Well setting myerrhandle to true seems that the error handling keeps on
working in
.net is it right? what's the difference from exception handling?
if exception handling is better like i think how can i do to pass from
errhandling to excection handling?
Some times i use on error resume next has got
handling exception an equivalent?
Thasnks
Best Regards
DavideR

Jan 11 '06 #2

P: n/a
The "One Error GoTo <label>" part of your VB6 error handling can be converted
automatically to .NET exception handling (download the demo of Clear VB on
our web site to see how).

The stuff that can't be converted easily includes 'On Error Resume Next'
statements. You need to enclose each statement in a try/catch block ("Try"
before the statement, and an empty "Catch" block after the statement). So,
unless your On Error Resume Next is only in effect for a single line or two,
this approach becomes impractical. This code needs to be reworked.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"DavideR" wrote:
I have converted a large vb6 program with an add-in that for every routine
gimme
the error handling:
the add-in adds one line on the head of the routine
"if myerrhandle then ON ERROR GOTO HERRHANDLER"
and the herrhandler label at the botton where i write in a logfile the name
of the routine, the errors and other information
Well setting myerrhandle to true seems that the error handling keeps on
working in
.net is it right? what's the difference from exception handling?
if exception handling is better like i think how can i do to pass from
errhandling to excection handling?
Some times i use on error resume next has got
handling exception an equivalent?
Thasnks
Best Regards
DavideR

Jan 11 '06 #3

P: n/a
in some routine like mousemove, graphical drawing etc i sometimes i use
resume next for continue execution of the code for not display a blank screen
(i display an incorrect screen but not blank(this is not my decision but its
so for a long time for customer's impact ! ?!?)
and then i re-establish the herrhandling
So nothing to do?? it's already allright?
Thanks for reply
:?)

"Patrice" wrote:
Yes, this is included for legacy. Actually the underyling MSIL code for on
error uses Try/Catch...

Try :
http://msdn.microsoft.com/library/de...Statements.asp

You are allowed to do nothing when an exception is raised but I would still
double check that I can't do otherwise (bascially it should IMO never be
done, what is your scenario ?).

--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4B**********************************@microsof t.com...
I have converted a large vb6 program with an add-in that for every routine
gimme
the error handling:
the add-in adds one line on the head of the routine
"if myerrhandle then ON ERROR GOTO HERRHANDLER"
and the herrhandler label at the botton where i write in a logfile the

name
of the routine, the errors and other information
Well setting myerrhandle to true seems that the error handling keeps on
working in
.net is it right? what's the difference from exception handling?
if exception handling is better like i think how can i do to pass from
errhandling to excection handling?
Some times i use on error resume next has got
handling exception an equivalent?
Thasnks
Best Regards
DavideR


Jan 11 '06 #4

P: n/a
What kind of errors have you *seen* in this portion of code ?

This is one point where try/cast can help as you can catch only those
exception that are of a given class. This way you can catch errors that
could arise (for example file io errrors when saving a file) but you can
still have more unexpected errors to raise a generic message and warns the
support team.

I wanted to convey the opinion that IMO the worst thing in error hanlding is
to "hide" errors that are not signaleds to the support team and/or the
user...


--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4E**********************************@microsof t.com...
in some routine like mousemove, graphical drawing etc i sometimes i use
resume next for continue execution of the code for not display a blank screen (i display an incorrect screen but not blank(this is not my decision but its so for a long time for customer's impact ! ?!?)
and then i re-establish the herrhandling
So nothing to do?? it's already allright?
Thanks for reply
:?)

"Patrice" wrote:
Yes, this is included for legacy. Actually the underyling MSIL code for on error uses Try/Catch...

Try :
http://msdn.microsoft.com/library/de...Statements.asp
You are allowed to do nothing when an exception is raised but I would still double check that I can't do otherwise (bascially it should IMO never be
done, what is your scenario ?).

--
Patrice

"DavideR" <Da*****@discussions.microsoft.com> a écrit dans le message de
news:4B**********************************@microsof t.com...
I have converted a large vb6 program with an add-in that for every routine gimme
the error handling:
the add-in adds one line on the head of the routine
"if myerrhandle then ON ERROR GOTO HERRHANDLER"
and the herrhandler label at the botton where i write in a logfile the
name
of the routine, the errors and other information
Well setting myerrhandle to true seems that the error handling keeps

on working in
.net is it right? what's the difference from exception handling?
if exception handling is better like i think how can i do to pass from
errhandling to excection handling?
Some times i use on error resume next has got
handling exception an equivalent?
Thasnks
Best Regards
DavideR


Jan 11 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.