I want to create public variables, but always want to pass the current value of the variable from one procedure to another. For Example:
-------------------
Option Explicit
Public X as Long
Public Y as Long
Public Z as Long
Sub A ()
X = 1
Y= 2
Z = X + Y
Call B
Worksheets (1).Range("A1").Value = Z
End Sub
Sub B ()
X = 2
Y=3
Z = X + Y
End Sub
----------------
In Cell A1 I want the value of 5 printed not the value of 3. Thus, I want the variables to be passed by value and not by reference. I want variables to pass by value globally.
Is this an appropriate procedure?
-----------
Option Explicit
Public X ByVal as Long
Public Y ByVal as Long
Public Z ByVal as Long
Sub A ()
X = 1
Y= 2
Z = X + Y
Call B
Worksheets (1).Range("A1").Value = Z
End Sub
Sub B ()
X = 2
Y=3
Z = X + Y
End Sub
----------------
-------------------
Option Explicit
Public X as Long
Public Y as Long
Public Z as Long
Sub A ()
X = 1
Y= 2
Z = X + Y
Call B
Worksheets (1).Range("A1").Value = Z
End Sub
Sub B ()
X = 2
Y=3
Z = X + Y
End Sub
----------------
In Cell A1 I want the value of 5 printed not the value of 3. Thus, I want the variables to be passed by value and not by reference. I want variables to pass by value globally.
Is this an appropriate procedure?
-----------
Option Explicit
Public X ByVal as Long
Public Y ByVal as Long
Public Z ByVal as Long
Sub A ()
X = 1
Y= 2
Z = X + Y
Call B
Worksheets (1).Range("A1").Value = Z
End Sub
Sub B ()
X = 2
Y=3
Z = X + Y
End Sub
----------------