

(Only useful if you need to check a specific error occurred.) When an error occurs the error information is stored here. Goes to a specific label when an error occurs. When error occurs, the code stops and displays the error.Ĭlears the current error setting and reverts to the default.

The Upgrade Wizard converts it using the same error management statements as in the original VB6 source code. MsgBox Err.Description,, "Error" End Sub Public Sub ErrorHandling(arg1 As Integer) The flow control of this source code extract will jump to the “ErrorHandler:” label in case there is an arithmetic error. The following VB6 extract shows a simple usage of the “On Error” statement to avoid a possible division by zero. NET, it is also necessary to convert the Err Object. NET equivalent “try … catch” blocks.Īs part of the full conversion of the Visual Basic 6 Error handling schema (On Error. All unused labels are removed from the resulting code, plus the most commonly used “On Error” patterns are currently recognized and replaced for native. The Visual Basic Upgrade Companion is able to remove unstructured “spaghetti code” and convert it to structured. These patterns are complex to read in VB6 and need to be removed from the resulting code for the sake of maintainability.

Also, VB6 features in-code labels that can be used to create confusable “jump” patterns. NET languages have different error handling techniques while VB.NET is able to support a small subset of VB6 error handling keywords, C#.NET is not.
