Solved

How to indentify a specific VB.Net error ?

Posted on 2003-11-04
3
155 Views
Last Modified: 2010-05-01
In VB 6, I can use the err.number to get the error's number and write code to handle that specific error.
but in VB.NET, how can i identify exactly what error is happening ?

and one more question, what is the differences between compiling a project or solution with debug mode and realease mode ?

Thanks,

Phat
0
Comment
Question by:nsophat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
brother7 earned 55 total points
ID: 9684403
Errors in VB.NET are called Exceptions.  To trap an Exception, you use a Try...Catch construction.  Sample code is below.

---Code Start---

Module Module1

   Sub Main()
      Dim x, y, z As Integer
      x = 100
      y = 0
      Try
         z = x / y
      Catch e As Exception
         Console.WriteLine(e.Message())
         Console.WriteLine(e.GetType())
      End Try

   End Sub ' Main

End Module ' Module1

--- Code End ---

The output of the following code is:
   Arithmetic operation resulted in an overflow.
   System.OverflowException

So when you talk about getting the error number, I think in .NET-speak, you want to retrieve the Type of the exception.
0
 

Author Comment

by:nsophat
ID: 9698698
What about the Debug and release mode ?

Please give advice,

Phat
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question