Let and Get array of fixed size
I have a class that has a fixed-size array of Double, for example
Private m_values(8) as Double
What is the correct syntax for the Let and Get methods for an 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
The specific parts of the syntax I am unclear about:
a. In the Let method, is RHS(8) as Double the correct way to pass an array of 8 Double? b. Can I copy one array to another simply using assignment? (e.g. m_values = values) c. For the Get method, is it correct for the function to be declared as Double or should it be something like as Double(8)?
The only way to declare a property that can hold arrays is as Variant property.
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