Solved

How to indentify a specific VB.Net error ?

Posted on 2003-11-04
3
154 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
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

837 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