COMVariant.variantType Method

Queries a COMVariant object for its variant data type or changes the data type.

Syntax

public COMVariantType variantType([COMVariantType newValue])

Run On

Called

Parameters

Return Value

Type: COMVariantType Enumeration
The current variant data type.

Remarks

The possible values for the newValue parameter are:

  • COMVariantType::VT_I2

  • COMVariantType::VT_I4

  • COMVariantType::VT_R4

  • COMVariantType::VT_R8

  • COMVariantType::VT_CY

  • COMVariantType::VT_DATE

  • COMVariantType::VT_BSTR

  • COMVariantType::VT_DISPATCH

  • COMVariantType::VT_ERROR

  • COMVariantType::VT_BOOL

  • COMVariantType::VT_VARIANT

  • COMVariantType::VT_UNKNOWN

  • COMVariantType::VT_DECIMAL

  • COMVariantType::VT_I1

  • COMVariantType::VT_UI1

  • COMVariantType::VT_UI2

  • COMVariantType::VT_UI4

The variant data type describes how the data that is stored in the object is treated when the object is used as an argument in a call to the COMDispFunction.call method or a call to the COM class.

If you change the data type, the data that is held in the object is deleted.

See the for information about the available variant data types.

Examples

The following example creates a new COMVariant object and sets it to be of long (VT_I4) data type. The variantType method is then used to change the data type to VT_DATE (date). The data that is held by the object is discarded.

{ 
    COMVariant var = new COMVariant(); 
  
    // Set the 'var' object to be a long 
    var.long(123); 
  
    // Change var so that it can store a date 
    var.variantType(COMVariantType::VT_DATE); 
}

See Also

COMVariant Class

COMDispFunction.call Method

COMVariant.new Method

COMVariant.variantType Method