Let and Get a fixed-size array

I have a class that has a fixed size array Doublelike

Private m_values(8) as Double

What is the correct syntax methods Letand Getan array?

Public Property Let Values (RHS(8) as Double)
    m_values = RHS
End Property

Public Property Get Values() as Double
    Values = m_values
End Property

Specific parts of the syntax that I don't understand about:

a. The method Lethas RHS(8) as Doublethe correct way to pass an array of 8 Double?
b. Can I copy one array to another just using the assignment? (e.g. m_values = values)
p. GetIs it correct for the method to declare a function, as Doubleor should it be something like as Double(8)?

+4
source share
2 answers

, , - Variant.

Private m_values As Variant

Public Property Let Values(RHS As Variant)
    m_values = RHS
End Property

Public Property Get Values() As Variant
    Values = m_values
End Property

Public Sub Test()
    Dim x(8) As Double
    x(1) = 123.55
    x(2) = 456.45
    x(5) = 789.66
    x(8) = 123.777

    ' assign value to property
    Values = x

    ' get value from property
    Dim y() As Double
    y = Values

    Dim i As Integer
    For i = 0 To UBound(y)
        Debug.Print y(i)
    Next

End Sub
+3

:

'starting point- array with 8 elements
Dim arrStart(8) As Double
    arrStart(8) = 1     'here- for testing with Local window

'passing array to another...Variant type variable
    'no array declaration required
Dim arrVariant As Variant
    arrVariant = arrStart

'passing array to another Double variable
    'dynamic array declaration required
Dim arrEmpty() As Double
    arrEmpty = arrStart

( ) , . , Get Property , Variant.

+2

All Articles