Q
Problem solve Get help with specific problems with your technologies, process and projects.

How has error handling been improved in VB.NET?

I've heard that error handling is much improved in VB.NET. Can you give me specific advantages compared to VB 6? Thanks.

I've heard that error handling is much improved in VB.NET. Can you give me specific advantages compared to VB6? Thanks.
VB.NET error handling has improved in two aspects: syntactically and functionally.

Syntactically, VB.NET improves error handling with the new Try/Catch/Finally keywords. This replaces the On Error Goto mess we dealt with in VB6. By the way, On Error Goto is still supported, you just cannot mix both that and Try/Catch/Finally within the same procedure.

Much more important however, is VB.NET's functional error handling improvements as implemented by the Exception class. If you are like me, then you have been frustrated with the lack of functionality provided by the VB6 Err object. Most annoying was the fact that it did not provide a stack trace (a history of procedure calls). That is extremely useful when trying to determine the exact execution path which caused the error. In VB.NET, all exceptions derive from the System.Exception type which provides stack trace functionality and much more. If that still is not good enough, you can derive your own custom exception classes from System.Exceptions and extend the functionality as needed.

Dig Deeper on VB 6 to VB .NET Migration

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

Close