• Saves Valuable Time
  • Trusted Accuracy for 14 Years
  • 15-Day Money-Back Guarantee

C# Equivalent to VB6 Error Handling

VB allows VB6-style error handling for compatibility purposes.  Some elements of VB6 error handling can be converted to try/catch blocks.  Items that cannot be converted and must be addressed via refactoring are: On Error Resume Next, Resume, Resume Next, On Error GoTo -1, and references to the Err object.

For the simplest case, the conversion is trivial:

Public Sub LegacyErrorHandling()

    On Error GoTo ErrorHandler
    '... main logic

    '... error handling code
End Sub
public void LegacyErrorHandling()
        //... main logic
        //... error handling code

Use Instant C# and Instant VB to convert between VB.NET and C#.     

Additional resource: VB.NET and C# Equivalents

Copyright © 1997 – 2018 Tangible Software Solutions Inc.