Solved

How to indentify a specific VB.Net error ?

Posted on 2003-11-04
3
157 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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