Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to indentify a specific VB.Net error ?

Posted on 2003-11-04
3
Medium Priority
?
160 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 165 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
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…
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…
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…
Suggested Courses

604 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