Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Goto vs if/esle

Goto vs if/esle

Scheduled Pinned Locked Moved The Weird and The Wonderful
visual-studio
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Not Active
    wrote on last edited by
    #1

    Bad enough its VB, they are even using a select for two cases when an Or would have sufficed.

    Select Case stringvalue.ToLower
    Case "a", "b"
    rslt = Format(CDbl(AmountB), "#,0.00")
    GoTo skpy
    If CheckPPSO Or CheckPRS Then
    If DownPayment >= Downpayment_Cutoff Then
    If CountryAbbr = "CA" Then
    rslt = Format(GetPrice(CodeLetter, "XYZ"), "#,0.00")
    Else
    rslt = Format(GetPrice(CodeLetter, "X"), "#,0.00")
    End If
    End If
    skpy:
    End If
    End Select

    This was in the middle of a larger switch with 246 case statements. Good thing it's Friday, I've stopped processing data after coming to this. Why are people who do this even allowed near computers :-D :rolleyes:


    No comment

    E B A 3 Replies Last reply
    0
    • N Not Active

      Bad enough its VB, they are even using a select for two cases when an Or would have sufficed.

      Select Case stringvalue.ToLower
      Case "a", "b"
      rslt = Format(CDbl(AmountB), "#,0.00")
      GoTo skpy
      If CheckPPSO Or CheckPRS Then
      If DownPayment >= Downpayment_Cutoff Then
      If CountryAbbr = "CA" Then
      rslt = Format(GetPrice(CodeLetter, "XYZ"), "#,0.00")
      Else
      rslt = Format(GetPrice(CodeLetter, "X"), "#,0.00")
      End If
      End If
      skpy:
      End If
      End Select

      This was in the middle of a larger switch with 246 case statements. Good thing it's Friday, I've stopped processing data after coming to this. Why are people who do this even allowed near computers :-D :rolleyes:


      No comment

      E Offline
      E Offline
      ekolis
      wrote on last edited by
      #2

      Ooh, nice, the "comment out code using a goto" pattern! :)

      1 Reply Last reply
      0
      • N Not Active

        Bad enough its VB, they are even using a select for two cases when an Or would have sufficed.

        Select Case stringvalue.ToLower
        Case "a", "b"
        rslt = Format(CDbl(AmountB), "#,0.00")
        GoTo skpy
        If CheckPPSO Or CheckPRS Then
        If DownPayment >= Downpayment_Cutoff Then
        If CountryAbbr = "CA" Then
        rslt = Format(GetPrice(CodeLetter, "XYZ"), "#,0.00")
        Else
        rslt = Format(GetPrice(CodeLetter, "X"), "#,0.00")
        End If
        End If
        skpy:
        End If
        End Select

        This was in the middle of a larger switch with 246 case statements. Good thing it's Friday, I've stopped processing data after coming to this. Why are people who do this even allowed near computers :-D :rolleyes:


        No comment

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        At least the compiler should have shown you where this one was (warning: unreachable code detected). But yes that is pretty bad!

        1 Reply Last reply
        0
        • N Not Active

          Bad enough its VB, they are even using a select for two cases when an Or would have sufficed.

          Select Case stringvalue.ToLower
          Case "a", "b"
          rslt = Format(CDbl(AmountB), "#,0.00")
          GoTo skpy
          If CheckPPSO Or CheckPRS Then
          If DownPayment >= Downpayment_Cutoff Then
          If CountryAbbr = "CA" Then
          rslt = Format(GetPrice(CodeLetter, "XYZ"), "#,0.00")
          Else
          rslt = Format(GetPrice(CodeLetter, "X"), "#,0.00")
          End If
          End If
          skpy:
          End If
          End Select

          This was in the middle of a larger switch with 246 case statements. Good thing it's Friday, I've stopped processing data after coming to this. Why are people who do this even allowed near computers :-D :rolleyes:


          No comment

          A Offline
          A Offline
          AdamEcc
          wrote on last edited by
          #4

          I don't code in VB, so I could be well off the mark here, but isn't that GoTo also going to take you to a point where your next statment is "End If", without having actually executed the corresponding "If"? Couldn't that have "interesting" effects?

          R 1 Reply Last reply
          0
          • A AdamEcc

            I don't code in VB, so I could be well off the mark here, but isn't that GoTo also going to take you to a point where your next statment is "End If", without having actually executed the corresponding "If"? Couldn't that have "interesting" effects?

            R Offline
            R Offline
            Rob Grainger
            wrote on last edited by
            #5

            Its probably safe in that sense, the compiler will most likely just put make the End If the target of a Jump instruction. For a loop, it would be horrible. In C++, that could cause RAII to break, but in VB its probably safe. No guarantees though (but where GOTO's are used, most guarantees are probably invalid anyway).

            A 1 Reply Last reply
            0
            • R Rob Grainger

              Its probably safe in that sense, the compiler will most likely just put make the End If the target of a Jump instruction. For a loop, it would be horrible. In C++, that could cause RAII to break, but in VB its probably safe. No guarantees though (but where GOTO's are used, most guarantees are probably invalid anyway).

              A Offline
              A Offline
              AdamEcc
              wrote on last edited by
              #6

              It's a long time since I've used "proper" C or C++, but in C#, it won't even compile as the label is out of scope of the goto :)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups