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