Is there a way to use the GOTO statement with a variable:

Dim S as ?
S = "Next"
goto S


I now use a Select Case statment.
Neal HartmanAsked:
Who is Participating?
clifABBConnect With a Mentor Commented:
A Select/Case statement is the only option you have.

For proper coding etiquet, you should avoid using Goto's.
The only proper reason for using a Goto is in place of an Exit Sub (or Exit Function).  Good code only has one entrance point and one exit point for each procedure.
Learn how to structure your program better
Mirkwood is right, but you can do it using constant variables though:

Option Explicit


Private Sub Form_Load()
    On Error GoTo cERROR_ROUTINE
    Err.Raise 13
    Exit Sub
    MsgBox Err.Number & " " & Err.Description
End Sub
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

i dunno why people hate the GOTO so much?? What's all the fuss about it?? GOTO is a simple JMP in ASM, which is used in the WHILE() loop.... what's all the bad talk about GOTO... Man, people hear something from somebody, and they tell the next person that same thing, without even giving any thought to whether that statement is true or not...

Everything is bad and dangerous if you don't know how to use it properly... If you do, then you will have no problems with it and might even benefit from its use...

Just my 2 cents.....

btw, why do so many people use WHILE() and nobody says that it's terrible and dangerous, and on the other hand everybody says that GOTO is bad?? As a matter of fact WHILE is even more dangerous than GOTO by itself.... u might get into an infinite loop any time, just like that....

Goto's are ok. but if you need a select statement to handle your goto's then you are on the wrong track.
Neal HartmanAuthor Commented:
OK, I get the hint. NO GOTO's!

rmcquade, GOTOs are OK as long as you're confident that you know how to use 'em appropriatelly...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.