CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Location
    Mississauga, CANADA
    Posts
    199

    GOTO redirects in VB.NET

    Finally getting into VB.net and tried converting an existing vb6 app. Going through the upgrade report, one thing sticks out...GOTO <label>. The code would read something like this:

    <some vb6 code>

    ON ERROR GOTO FixErr

    <some vb6 code>

    ResumeFromErr:
    <some vb6 code>

    FixErr:
    if <some vb6 code> then
    GOTO ExitSub
    else
    GOTO ResumeFromErr
    end if

    ExitSub:
    <some vb6 code>
    Exit Sub

    In the error report, it shows that the lables shown above are not declared? I can substitute line numbers and it will work. The help file doesn't help. Can anyone point me in the right direction?
    Thanks
    Paul
    Paul

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    I'd get rid of all the GOTOs and replace with Try...Catch...Finally blocks. GOTO's have been considered "bad" for a long time! (Although that was the only way to handle errors in VB until now).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured