Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17



Posted on 1999-07-02
Medium Priority
Last Modified: 2011-10-03
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.
Question by:Neal Hartman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Expert Comment

ID: 1521532
Learn how to structure your program better

Accepted Solution

clifABB earned 150 total points
ID: 1521533
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.

Expert Comment

ID: 1521534
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 10

Expert Comment

ID: 1521535
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.....

LVL 10

Expert Comment

ID: 1521536
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....

LVL 13

Expert Comment

ID: 1521537
Goto's are ok. but if you need a select statement to handle your goto's then you are on the wrong track.

Author Comment

by:Neal Hartman
ID: 1521538
OK, I get the hint. NO GOTO's!

LVL 10

Expert Comment

ID: 1521539
rmcquade, GOTOs are OK as long as you're confident that you know how to use 'em appropriatelly...

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question