Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED VARIABLE TO SHARE BETWEEN PROCS AND IS STATIC TYPE 2

Status
Not open for further replies.

TNN

Programmer
Sep 13, 2000
417
US
I have 2 procedures. One calls the other numerous times from a FOR loop. I need a variable that can be updated in the called proc and read from the calling proc AND RETAINS ITS VALUE BETWEEN CALLS.
A Static variable won't work because it is local only.
Any Suggestions please.
TNN, Tom
TNPAYROLL@AOL.COM



TOM
 
Do you mean you have this situation:

Procedure1
variable in here which is changed in Procedure2
End Procedure1

Procedure2
needs to alter the value of variable in Procedure1
End Procedure2

????????????

If you do, when you call Procedure2, you should pass the variable ByRef, so that Procedure2 will be something like this:

Private Sub Procedure2(ByRef vVariableName As Type)
' change the variable vVariableName
End Sub

Passing variables ByRef really just passes a pointer to the original variable, whereas passing variables ByVal will create a copy of the original variable so that any changes made will not affect the original variable.
Simon
 
Declaring a variable as public inside a module make variable assessable in all forms.
David Paulson


 
A more object oriented approach would be to create a property of the form you are using to store the variable you need in procedure 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top