Passing an array to a Property Let Procedure

Hi:

In a class module I have declared a private variable as an array, and have written a Public Let Property to recieve a list of arguments as an array which will then populate my private variable. I am having trouble finding the correct syntax to pass the array.

I have tried:

object.ReturnFields = "a","b","c"
object.ReturnFields = ("a","b","c")

and other variations, all of which produce various error messages.


This is the code I have in my class module:

Private aryReturnFields() as string

Public Property Let ReturnFields(ByRef vNewValue() As String)

ReDim aryReturnFields(UBound(vNewValue())) As String

For x = LBound(vNewValue()) To UBound(vNewValue())
aryReturnFields = vNewValue(x)
Next x

End Property


Comments

  • : Hi:
    :
    : In a class module I have declared a private variable as an array, and have written a Public Let Property to recieve a list of arguments as an array which will then populate my private variable. I am having trouble finding the correct syntax to pass the array.
    :
    : I have tried:
    :
    : object.ReturnFields = "a","b","c"
    : object.ReturnFields = ("a","b","c")
    :
    : and other variations, all of which produce various error messages.
    :
    :
    : This is the code I have in my class module:
    :
    : Private aryReturnFields() as string
    :
    : Public Property Let ReturnFields(ByRef vNewValue() As String)
    :
    : ReDim aryReturnFields(UBound(vNewValue())) As String
    :
    : For x = LBound(vNewValue()) To UBound(vNewValue())
    : aryReturnFields = vNewValue(x)
    : Next x
    :
    : End Property
    :
    :
    :

    The correct syntax would be

    [code]Dim YourArray() As String
    YourArray = Split("""a"",""b"",""c""") 'puts the string into an array
    object.ReturnFields(YourArray)[/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion