Perils of GoTo
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Perils of GoTo
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    MrExcel MVP Von Pookie's Avatar
    Join Date
    Feb 2002
    Location
    The act or process of locating.
    Posts
    13,686
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Perils of GoTo

    Kristy

  2. #2
    Board Regular MorganO's Avatar
    Join Date
    Nov 2006
    Location
    Springfield Oregon
    Posts
    483
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    That is hilarious!

    I learned Basic as my first programming language 30 years ago and Goto was the only branching option available. I have over the years grown away from using but occasionally come upon a situation where I really want to use it, and am stymied by the years of being beat over the head that Goto's were EVIL!

    This cartoon captures the essence of my internal struggles perfectly!

    Owen
    Check out my game - EXCEL ROCKS! A scrolling, platform type computer game programmed in Excel VBA - based on the old Commodore 64 game Boulderdash. www.justforfun.us/excelrocks

  3. #3
    Board Regular Lewiy's Avatar
    Join Date
    Jan 2007
    Location
    Hyrule
    Posts
    4,282
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there actually a situation where you would absolutely have to use a GoTo? (referring to VBA in particular). Personally I donít even think about them when Iím writing code, Iíve never used one in VBA and never intend to!! My earliest programming was done as a little kid using TIBasic on a Texas Instruments graphical calculator. It was fairly limited in functionality so I got into the habit of using GoTo for most loops but my father always reprimanded me for it so I soon changed my ways and never looked back since! God bless parents!!
    Give a man a fish, he'll eat for a day.
    Teach a man to fish, he'll eat for a lifetime.
    Give a man religion, he'll die praying for a fish.

  4. #4
    MrExcel MVP
    Moderator
    Inactive
    Richard Schollar's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    23,703
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default

    Well,

    On Error Goto Err_Handler

    utilises a Goto and my VBA apps would be much the worse for not incorporating something like this...

    Richard Schollar

    Using xl2013

  5. #5
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,027
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    11 Thread(s)

    Default

    Yep, a lot of people (including myself) use them in Error Handling (and it usually just to jump to the end, do some debugging and exit).

    However, that is the only place that I use them.
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  6. #6
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    75,108
    Post Thanks / Like
    Mentioned
    60 Post(s)
    Tagged
    6 Thread(s)

    Default

    So that's what happened to the guy in Jurassic Park.

    A velociraptor found he was using GoTo unnecessarily in his code and decided to take the appropriate action.
    If posting code please use code tags.

  7. #7
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,027
    Post Thanks / Like
    Mentioned
    52 Post(s)
    Tagged
    11 Thread(s)

    Default

    Kind of reminds me of Terry Tate, Office Linebacker:
    http://www.youtube.com/watch?v=MRkiouh5NEI
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  8. #8
    Board Regular Lewiy's Avatar
    Join Date
    Jan 2007
    Location
    Hyrule
    Posts
    4,282
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    So that's what happened to the guy in Jurassic Park.

    A velociraptor found he was using GoTo unnecessarily in his code and decided to take the appropriate action


    Code:
    Sub ParkSecurity()
    On Error GoTo WaitingHelicopter
    If Dinosaur.Escape = True then
    	FrozenEmbryos.InBag = True
    	FatDude.TravelSpeed = Fast
    	If ParkJeep.InRain.Reliability < Average then
    		Rain = xlVeryHeavy
    	End If
    End If
    Select Case SmallFrillyDinosaur
    	Case Squeaks
    		FatDude.Affection = High
    	Case Growls
    		FatDude.Affection = Medium
    	Case Screams
    		FatDude.Affection = Low
    		FatDude.Pants = Brown
    		FatDude.Intelligence = xlVeryStupid
    End Select
    If FatDude.Pants <> White then
    	FatDude.Alive = False
    	MsgBox ďUh, Uh, Uh, You didnít say the magic word!!!Ē
    End If
    End Sub
    Give a man a fish, he'll eat for a day.
    Teach a man to fish, he'll eat for a lifetime.
    Give a man religion, he'll die praying for a fish.

  9. #9
    Board Regular
    Join Date
    Jun 2007
    Location
    Fredericksburg, Va
    Posts
    200
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    VBA humor...gotta love it!!!!

    This whole thread is hilarious...thanks guys!
    ...in and not of it.

  10. #10
    MrExcel MVP HalfAce's Avatar
    Join Date
    Apr 2003
    Location
    Alaska
    Posts
    9,453
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Lewiy:
    I like the 'FatDude' code.

    Good job.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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