VariantCopyInd
f90VB Modules
f90VBDefs, f90VBVariants
Summary
Frees the destination variant and makes a copy of the source variant, performing the necessary indirection if the source contains the VT_BYREF flag.
Syntax
| subroutine VariantCopyInd | (VarSrc, VarDest, iRet) |
| type(VARIANT),intent(in):: | VarSrc |
| type(VARIANT),intent(inout):: | VarDest |
| integer(HRESULT_KIND),intent(out),optional:: | iRet |
Arguments
VarSrc [Input]
Variant to be copied (source variant).
VarDest [Input/Output]
Variant that will contain the de-referenced copy of VarSrc (destination variant). VarDest must be an initialized variant.
iRet [Output/Optional]
Upon return, iRet contains S_OK or an error code. See comments for more information.
Comments
VariantCopyInd first calls VariantClear on the destination variant (VarDest) to clear any contents the destination variant may have. It then proceeds to write a copy of the source variant into the destination variant.
If VarSrc contains the VT_BYREF flag, the source variant is de-referenced before it is copied to VarDest. For example, if VarSrc is of type VT_BYREF+VT_R4, the destination variant will be of type VT_R4. The same is true for all other VT_BYREF combinations. VariantCopyInd de-references the source variant up to two levels of indirection (which is the maximum legal indirection level for variants). So if the source variant is of type VT_BYREF+VT_VARIANT and the referenced variant is, for example, VT_BYREF+VT_I4, the destination variant will be of type VT_I4.
If the source variant does not contains the VT_BYREF flag, VariantCopyInd behaves exactly the same as subroutine VariantCopy.
Note that the destination variant must be an initialized variant and its original contents will be freed by this subroutine.
Argument iRet
Indicates success or failure of the subroutine. The following codes can be returned in this argument:
| Value returned in argument iRet | Description | |
| S_OK | Success. | |
| DISP_E_BADVARTYPE | The source or destination variants have an invalid vtType. This usually happens when the variants have not been initialized. | |
| DISP_E_ARRAYISLOCKED | The destination variant contains an array that is locked | |
| E_INVALIDARG | One of the arguments is invalid. | |
| E_OUTOFMEMORY | Memory could not be allocated for the destination variant. | |
Examples
See examples for VariantCopy.
Related Topics
| For information about: | See: | |
| Changing the type of a variant | VariantChangeType | |
| Copying a Variant | VariantCopy | |