Solved

How to indentify a specific VB.Net error ?

Posted on 2003-11-04
3
151 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now