Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Pamela Baker   on Mar 02 In MS Office Category.

  
Question Answered By: Ann Evans   on Mar 02

It has to be defined  *somewhere*. Here is the "sequence"...

' ------------------------------------
sub Main()

dim LocalToMainParameter1
dim LocalToMainParameter2

subToCall LocalToMainParameter1, LocalToMainParameter2

MsgBox LocalToMainParameter2

end sub
' ------------------------------------
sub subToCall(LocalToSubParameter1, LocalToSubParameter2)

' Do stuff to initialise and set LocalToSubParameter2
' according to LocalToSubParameter1.

end sub
' ------------------------------------

In this, and leaving out the details though, FOUR variables  are
defined. The 2 for Main() are Local to that procedure only and are
passed to subToCall which instantiates another TWO. The VALUES of the
varaibles are passed here. After setting up the 2nd variable  the sub
stops. The VALUE of LocalToSubParameter2 is then passed back  to
LocalToMainParameter2 and I've used  MsgBox to display it with nods to
Greg about Debug.Print :-) As Greg says you can set things up to save
a bit of space and processing by just passing  the address of the first
variable.

When subToCall stops competely it hands anything it's used back to the
system and the LocalToMainParameter1 and LocalToMainParameter2 are no
more... they go to meet their maker... dead... deceased... definately
not just sleeping or resting with their eyes closed.

If you want a full code  example just shout and I'll try and do one...
that may take a bit though but I have no problems with you asking.

Share: 

 

This Question has 10 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Fundamental Q: passing/returning variables Or get search suggestion and latest updates.