On Error to Try Catch

    This feature allows the VB6 AI Migrator to recognize most of the “On Error” patterns and replace the unmanaged error handling by Try ... Catch statements. Some very complex spaghetti-code patterns wouldn’t be recognized by VB6 AI Migrator, but it already recognizes a large amount of cases with different combinations of statement (On Error Goto, Labels, Goto, Resume, Exit Sub/Function, Break, etc.)

    Some straightforward examples are shown below.

    Example 1 (simple case with block finalizer):

    [VB6]

    On Error Goto errLabel
    <CodeBlock1>
    <Exit Sub/Function>
    errlabel:
    <CodeBlock2>

    [C#.NET]

    try
    {
    <CodeBlock1>
    <Return>
    }
    catch
    {
    <CodeBlock2>
    }

    Example 2 (simple case with no block finalizer):

    [VB6]

    On Error Goto errLabel
    <CodeBlock1>
    <Exit Sub/Function>
    errlabel:
    <CodeBlock2>

    [C#.NET]

    try{
    <CodeBlock1>
    <Return>
    }catch{
    <CodeBlock2>
    }

    Example 3 (common case with resume statement):

    [VB6]

    On Error Goto errLabel
    <CodeBlock1>
    resumeLabel:
    <CodeBlock2>
    <Exit Sub/Function>
    errlabel:
    <CodeBlock3>
    Resume resumeLabel

    [C#.NET]

    try{
    <CodeBlock1>
    <Return>
    }catch{
    <CodeBlock3>
    }
    finally 
    {
    <CodeBlock2>
    }

    Download VB6 AI Migrator Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration