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

x
?
Solved

Return command for a GoTo Command question for VB

Posted on 2004-08-08
1
Medium Priority
?
566 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 1500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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