Solved

Return command for a GoTo Command question for VB

Posted on 2004-08-08
1
523 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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now