Goto: & Labels

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Option^Explicit

    #1

    Goto: & Labels

    What example can someone give to show how to use Goto Label: , but not to be
    used for error control.
    What if I want to use it to skip across a bunch of code?




  • J French

    #2
    Re: Goto: & Labels

    On Tue, 19 Aug 2003 05:57:00 GMT, "Option^Explici t"
    <techsmail%@sha w.ca> wrote:
    [color=blue]
    >What example can someone give to show how to use Goto Label: , but not to be
    >used for error control.
    >What if I want to use it to skip across a bunch of code?[/color]


    For L9 = 1 To Max
    If A$(L9) = "" Then GoTo SKIP
    ....

    SKIP:
    Next

    However, be very careful using GoTo,
    - its use is strongly deprecated by most programmers
    - primarily because it used to be (ab)used
    - creating tangled unreadable code

    IMO - only use it if all practical alternatives produce *less*
    readable code

    You would be well advised setting yourself some strict rules for its
    use

    Comment

    • Rick Rothstein

      #3
      Re: &amp; Labels

      > What example can someone give to show how to use Goto Label: , but not to
      be[color=blue]
      > used for error control.
      > What if I want to use it to skip across a bunch of code?[/color]

      You should go out of your way to avoid using Goto, using it only when the
      alternative is unreadable. So you understand, it is never "necessary" to use
      Goto, there is always an alternative. To answer your direct question... if
      you have code you wish to skip over, it is because some condition is not
      being met. To state that another way, you want to execute you bunch of code
      only if some condition is being met. You can do that with an If-Then-EndIf
      block.

      .......
      .......
      If SomeConditionIs Met Then
      .....
      .....
      your bunch of code
      .....
      .....
      End If
      ......
      ......

      Rick - MVP


      Comment

      Working...