Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

call sub at goto label position

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zSplash - 15 Sep 2005 20:01 GMT
I have a sub (test1) with a goto label (gotHere).  If I call that sub from
another sub, is there any way to call that sub, and go directly to the
label?  Like, in the following example, if I want to be at the "gotHere"
label in test1, when I call test1 from test2, how would I do that?

sub test1
   dim X as integer
   "blah, blah, blah code"
   If x =3 then
       goto gotHere
   endif
   "blah, blah, blah code"
gotHere:
   msgbox "Got it"
end sub

sub test2
   test1 ... [...at gotHere location in test1...]
end sub

TIA
Jay Freedman - 15 Sep 2005 22:05 GMT
> I have a sub (test1) with a goto label (gotHere).  If I call that sub
> from another sub, is there any way to call that sub, and go directly
[quoted text clipped - 18 lines]
>
> TIA

Hi z,

You can't call directly to the label, but you can pass a parameter that you
test immediately:

Sub Test1A(X As Integer)
' eliminate the  Dim X As Integer -- parameter serves as declaration
  If X = 3 Then GoTo gotHere
  ' other code
gotHere:
  MsgBox "Got it"
End Sub

Sub Test2A
   Test1A  X:=3
   '  or just Test1A  3
End Sub

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

zSplash - 15 Sep 2005 22:30 GMT
Thanks so much, Jay.

st.

> > I have a sub (test1) with a goto label (gotHere).  If I call that sub
> > from another sub, is there any way to call that sub, and go directly
[quoted text clipped - 36 lines]
>     '  or just Test1A  3
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.