cArray: CreateInstance

CreateInstance

Initializes a new array of the specified type in up to 3 dimensions.



 Public Function CreateInstance(
	  ByVal ArrayType As ciArrayTypes,
	  Optional ByVal length1 As Long = 0,
	  Optional ByRef length2 As Variant,
	  Optional ByRef length3 As Variant ) As Variant

Parameters

ArrayType
[ByVal] ciArrayTypes. The data type the array represents.
length1
[ByVal] Optional. Long. The number of elements in the first dimension.  

Default: 0

length2
[ByRef] Optional. Variant. The number of elements in the second dimension.
length3
[ByRef] Optional. Variant. The number of elements in the third dimension.

Return Values

Variant - 

Remarks

If a length is zero, then an empty array is returned, not a Null array. If one length is defined as zero, then all other defined lengths must be zero. This does not mean that lenghts 2 and 3 need to be set to zero if only an empty one-dimensional array is being created.

Elements of a size that are a multiple of 4 will not create a new array when being returned. All other datatype sizes will cause a new array to be created. The array must also be assigned at the end of the code so VB can optimize returning the Variant datatype and not copy it when possible.

See Also

Project VBCorLib Overview Class cArray Overview cArray Properties cArray Methods CopyEx Exists