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

Error handling in vb. net

P: n/a
Hi all

I'am moving from Visual Foxpro and have a question
regarding "best practice" error handling in vb .net.
In VFP I have always used a "central" error handling
object in order to have a easy and reusable way of
handling all errors in a program.

The VB 6 coding examples I have seen there has always
been error handling code in each program module.

Is it possible in VB .net to use a central error handling
or is it not a "good way" of handling errors?

Stefan Johansson
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Stefan,

Try reading up on the:

Try
Catch
End Try

... method for error handling. I find it to be very easy to implement
and you can plop it pretty much anywhere you need to. I find this easier to
implement than trying to put everything into a centralized error handler
myself, but that's just personal preference I guess. Not really sure if
there is an advantage to one way versus another.

~Brian

"Stefan Johansson" <du******@hotmail.com> wrote in message
news:05****************************@phx.gbl...
Hi all

I'am moving from Visual Foxpro and have a question
regarding "best practice" error handling in vb .net.
In VFP I have always used a "central" error handling
object in order to have a easy and reusable way of
handling all errors in a program.

The VB 6 coding examples I have seen there has always
been error handling code in each program module.

Is it possible in VB .net to use a central error handling
or is it not a "good way" of handling errors?

Stefan Johansson

Nov 20 '05 #2

P: n/a
Cor
Hi Stefan,

In addition to Brian, look also for "finally" .

Try
Just do what you want to do
Catch spEx as (a specialException)
DoSomething (by instance show a messagebox and do an action)
Catch Ex as Exception (you can real put those two ore more behind each
other)
(that catch every exception was not a special exception)
DoSomething (by instance show a messagebox and do an action)
Finally
(That is always done, it is very handy to close something )
End Try

I'am moving from Visual Foxpro and have a question
regarding "best practice" error handling in vb .net.
In VFP I have always used a "central" error handling
object in order to have a easy and reusable way of
handling all errors in a program.

The VB 6 coding examples I have seen there has always
been error handling code in each program module.

Is it possible in VB .net to use a central error handling
or is it not a "good way" of handling errors?

Nov 20 '05 #3

P: n/a
* "Stefan Johansson" <du******@hotmail.com> scripsit:
I'am moving from Visual Foxpro and have a question
regarding "best practice" error handling in vb .net.
In VFP I have always used a "central" error handling
object in order to have a easy and reusable way of
handling all errors in a program.

The VB 6 coding examples I have seen there has always
been error handling code in each program module.

Is it possible in VB .net to use a central error handling
or is it not a "good way" of handling errors?


In VB.NET, there are 2 error handling methods available: Structured
exception handling with 'Try...Catch' and unstructured error handling
with 'On Error GoTo...'. Have a look at the documentation for more
information on this topic.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.