473,382 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Error handling in vb. net

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
3 2826
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
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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WSeeger | last post by:
When creating a new class, is it encouraged to always include error handling routines within your LET and GET procedures? It's seems that most text books never seem to include much about error...
12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
9
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.