Carrying variable values to new subs
I have a rountine that has the variable 'Validate' dimensioned as boolean.
When the user clicks a command button on a associated userform I want to carry the value of 'Validate' (True or False) to the Private Sub CommandButton_Click.
How is this done?
Many thanks in advance for any help.
Re: Carrying variable values to new subs
The only way I know to do it is to make your variable public.
VB Code:
Public Validate As Boolean
Re: Carrying variable values to new subs
probably better done with a class -
say the class is clsValidate, set the Validate property by instantiating the class.
VB Code:
Dim retValue as Boolean
Dim oValidate As clsValidate
Set oValidate = New clsValidate
' write value
oValidate.Validate = True
' read value
retValue = oValidate.Validate
you can then read/write to this property anytime..
put this code into a class:
VB Code:
Private pValidate As Boolean
Public Property Get Validate() As Boolean
Validate = pValidate
End Property
Public Property Let Validate(ByVal value As Boolean)
pValidate = value
End Property