Help Center

DSAFEARRAY.Constructorconstructor

Creates a DSAFEARRAY.

COMconstructorDSafeArray.incdocumented

Syntax

CONSTRUCTOR DSAFEARRAY (BYVAL vt AS VARTYPE, BYVAL cDims AS UINT, BYVAL prgsabounds AS SAFEARRAYBOUND PTR)
CONSTRUCTOR DSAFEARRAY (BYREF strType AS STRING, BYVAL cDims AS UINT, BYVAL prgsabounds AS SAFEARRAYBOUND PTR)
CONSTRUCTOR DSAFEARRAY (BYVAL vt AS VARTYPE, BYVAL cElements AS ULONG = 0, BYVAL lLBound AS LONG = 0)
CONSTRUCTOR (BYREF strType AS STRING, BYVAL cElements AS ULONG = 0, BYVAL lLBound AS LONG = 0)
CONSTRUCTOR DSAFEARRAY (BYVAL vt AS VARTYPE, BYVAL cElements1 AS ULONG, BYVAL lLBound1 AS LONG, BYVAL cElements2 AS ULONG, BYVAL lLBound2 AS LONG)
CONSTRUCTOR (BYREF strType AS STRING, BYVAL cElements1 AS ULONG, BYVAL lLBound1 AS LONG, BYVAL cElements2 AS ULONG, BYVAL lLBound2 AS LONG)

Parameters

NameDescription
vtThe base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal.
strTypeThe base type of the array as a string literal.
cDimsNumber of dimensions in the array. The number cannot be changed after the array is created.
rgsaboundPointer to a vector of bounds (one for each dimension) to allocate for the array.
vtThe base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal.
strTypeThe base type of the array as a string literal.
cElementsOptional. Number of elements in the array.
lLBoundOptional. The lower bound of the array.
vtThe base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal.
strTypeThe base type of the array as a string literal.
cElements1Number of elements in the first dimension of the array.
lLBound1The lower bound of the first dimension of the array.
cElements2Number of elements in the second dimension of the array.
lLBound2The lower bound of the second dimension of the array.

Description

Creates a DSAFEARRAY.

Multidimensional array:

One-dimensional array:

Two-dimensional array:

Example

' // Two-dimensional array of BSTR ' // 2D: elements = 5, lower bound = 1 ' // 2D: elements = 3, lower bound = 1 DIM rgsabounds(0 TO 1) AS SAFEARRAYBOUND = {(5, 1), (3, 1)} DIM dsa AS DSAFEARRAY = DSAFEARRAY(VT_BSTR, 2, @rgsabounds(0)) -or- ' // Two-dimensional array of BSTR DIM dsa AS DSAFEARRAY = DSAFEARRAY(VT_BSTR, 5, 1, 3, 1)

' // One-dimensional array of VT_VARIANT with 0 elements and a lower-bound of 0 DIM dsa AS DSAFEARRAY = DSAFEARRAY(VT_VARIANT, 0, 0) -or- DIM dsa AS DSAFEARRAY = DSAFEARRAY(VT_VARIANT)

' // One-dimensional array of VT_BSTR with 5 elements and a lower-bound of 1 DIM dsa AS DSAFEARRAY = DSAFEARRAY(VT_BSTR, 5, 1)

Reference

  • Include file DSafeArray.inc
  • Defined in AfxNova/DSafeArray.inc:213
  • Documented in COM/DSAFEARRAY Class.md
  • Topic: DSAFEARRAY Class