Solved

Return command for a GoTo Command question for VB

Posted on 2004-08-08
1
543 Views
Last Modified: 2006-11-17
For a Goto Command, is there VB code that says Goto a different line run that code and then a RETURN COMMAND that returns the execution to the original code position and pick up where it was left off.  All this being in the same subroutine.

Thanks.
0
Comment
Question by:tqwu
1 Comment
 
LVL 12

Accepted Solution

by:
fulscher earned 500 total points
ID: 11746074
I'm afraid there's no such command. You would have to work with two Goto statements:


...
   Dosomething
   Domore
   Goto LabelB
LabelA:
   Domore
   Domore
   Exit Sub

LabelB:
   Doanotherthing
   Goto LabelA

Anyway, using GOTO statements is considered poor programming practice. In your case, wouldn't a SUB be better?

...
   Dosomething
   Domore
   Call SubB
   Domore
   Domore
   Exit Sub

Sub SubB
   ...
End Sub

Of course, you can't easily share variables between the calling code and SubB. Two possible solutions:
- Put the common variables in the header of the module (again, poor programming practice)
- pass the variables by reference to SubB.

Hope this helps
Jan
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server 2008 R2 - stored prodecure with execution plan make faster 24 123
Write Caching in the Cloud for VFP9 16 116
SSRS troubles 4 51
error in my cursor 5 32
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 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