Note that there are some explanatory texts on larger screens.

plurals
  1. POVBA Array of variant type as class property
    text
    copied!<p>I have a class that handles several numeric arrays (type double) and also needs to handle an array of descriptors, which will include a mix of strings and integers, which need to be utilized as strings and numbers accordingly. So I decide to make an array property of type variant (not a variant containing an array). But this one does not seem to work, while the type double arrays do. </p> <p>Specifically, this type double array-property works fine, to receive or return an array all at once:</p> <pre><code>Private p_dbNumericArray() As Double Public Property Let NumericArray(Value() As Double) p_dbNumericArray() = Value() End Property Public Property Get NumericArray() As Double() NumericArray() = p_dbNumericArray() End Property </code></pre> <p>But when I try the same pattern with an array of type variant, the Get property returns an empty/unallocated variant array: </p> <pre><code>Private p_vaVariantArray() As Variant Public Property Let VariantArray(Value() As Variant) p_vaVariantArray() = Value() End Property Public Property Get VariantArray() As Variant() VariantArray() = p_vaVariantArray() End Property </code></pre> <p>Wrapping an array in a variant (instead of having an array of type variant), of course works fine:</p> <pre><code>Private p_vaVariantArray As Variant Public Property Let VariantArray(Value As Variant) p_vaVariantArray = Value End Property Public Property Get VariantArray() As Variant VariantArray = p_vaVariantArray End Property </code></pre> <p>But is it known and standard that the pattern that works for Dim D() As Double does not work for Dim V() As Variant, in properties? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload