Results 1 to 3 of 3

Thread: Carrying variable values to new subs

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    50

    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.

  2. #2
    Lively Member
    Join Date
    Jun 2005
    Posts
    112

    Re: Carrying variable values to new subs

    The only way I know to do it is to make your variable public.

    VB Code:
    1. Public Validate As Boolean

  3. #3
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    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:
    1. Dim retValue as Boolean
    2. Dim oValidate As clsValidate
    3. Set oValidate = New clsValidate
    4.  
    5. ' write value
    6. oValidate.Validate = True
    7.  
    8. ' read value
    9. retValue = oValidate.Validate

    you can then read/write to this property anytime..

    put this code into a class:

    VB Code:
    1. Private pValidate As Boolean
    2.  
    3. Public Property Get Validate() As Boolean
    4.     Validate = pValidate
    5. End Property
    6. Public Property Let Validate(ByVal value As Boolean)
    7.     pValidate = value
    8. End Property

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width