DSAFEARRAY.Insertmethod
Inserts a value at the specified position of the safe array.
Syntax
FUNCTION Insert (BYVAL nPos AS LONG, BYVAL pData AS ANY PTR) AS HRESULT
FUNCTION Insert (BYVAL nPos AS LONG, BYREF bsData AS BSTRING) AS HRESULT
FUNCTION Insert (BYVAL nPos AS LONG, BYREF dvData AS DVARIANT) AS HRESULT
FUNCTION Insert (BYVAL nPos AS LONG, BYVAL vData AS VARIANT) AS HRESULT
FUNCTION Insert (BYVAL pData AS ANY PTR) AS HRESULT
FUNCTION Insert (BYREF bsData AS BSTRING) AS HRESULT
FUNCTION Insert (BYREF dvData AS DVARIANT) AS HRESULT
FUNCTION Insert (BYVAL vData AS VARIANT) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
nPos | Optional. Index of the array in which the data will be inserted. If nPos is not specified, the item is inserted at the beginning of the array. If the array is empty, it is redimensioned to one element. | |
pData | Pointer to a variable of the appropriate data type. | |
bsData | The BSTRING to insert, if the safe array is of type VT_BSTR. | |
dvData | The DVARIANT to insert, if the safe array is of type VT_VARIANT. | |
vData | The VARIANT to insert, if the safe array is of type VT_VARIANT. |
Return value
S_OK (0) on success or an HRESULT code on failure.
Description
Inserts a value at the specified position of the safe array.
Inserts a value at the beginning of the safe array.
Inserts a string.
Inserts a variant.
Example
' // Create a one-dimensional array of variants 'DIM dsa AS DSAFEARRAY = DSAFEARRAY(VT_VARIANT, 2, 1) DIM dsa AS DSAFEARRAY = DSAFEARRAY("VARIANT", 2, 1)
dsa.PutVar(1, "Test string 1") dsa.PutVar(2, "Test string 2") dsa.InsertVar(2, 12345.67)
DIM dvOut AS DVARIANT dsa.Get(1, dvOut) print dvOut dsa.Get(2, dvOut) print dvOut dsa.Get(3, dvOut) print dvOut
Reference
- Include file
DSafeArray.inc - Defined in AfxNova/DSafeArray.inc:1783
- Documented in COM/DSAFEARRAY Class.md
- Topic: DSAFEARRAY Class