DSAFEARRAY.Constructorconstructor
Creates a DSAFEARRAY.
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
| Name | Description | |
|---|---|---|
vt | The 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. | |
strType | The base type of the array as a string literal. | |
cDims | Number of dimensions in the array. The number cannot be changed after the array is created. | |
rgsabound | Pointer to a vector of bounds (one for each dimension) to allocate for the array. | |
vt | The 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. | |
strType | The base type of the array as a string literal. | |
cElements | Optional. Number of elements in the array. | |
lLBound | Optional. The lower bound of the array. | |
vt | The 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. | |
strType | The base type of the array as a string literal. | |
cElements1 | Number of elements in the first dimension of the array. | |
lLBound1 | The lower bound of the first dimension of the array. | |
cElements2 | Number of elements in the second dimension of the array. | |
lLBound2 | The 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