Solved

Return command for a GoTo Command question for VB

Posted on 2004-08-08
1
559 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
[X]
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
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

 Database Backup and Recovery Best Practices

Join Percona’s, Architect, Manjot Singh as he presents Database Backup and Recovery Best Practices (with a Focus on MySQL) on Thursday, July 27, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7). In the case of a failure, do you know how long it will take to restore your database?

Question has a verified solution.

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

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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…

627 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