Help Center

DSAFEARRAY.InsertStrmethod

COMmethodDSafeArray.incdocumented

Syntax

FUNCTION InsertStr (BYVAL nPos AS LONG, BYVAL pwszData AS WSTRING PTR) AS HRESULT
FUNCTION InsertStr (BYVAL pwszData AS WSTRING PTR) AS HRESULT
Also documented as Insert — one description covers them all.

Parameters

NameDescription
nPosOptional. 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.
pDataPointer to a variable of the appropriate data type.
bsDataThe BSTRING to insert, if the safe array is of type VT_BSTR.
dvDataThe DVARIANT to insert, if the safe array is of type VT_VARIANT.
vDataThe 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:1839
  • Documented in COM/DSAFEARRAY Class.md
  • Topic: DSAFEARRAY Class