The Variant Class contains the following constructors:
Variant()
Variant(int val)
Variant(double val)
Variant(boolean val)
Variant(string val)
Variant(SafeArray val, boolean fByRef)
Variant(object value)
Variant(int vartype, int val)
Variant(int vartype, boolean val)
Variant(int vartype, double val)
Variant(int vartype, Object val)
Variant(Object value, boolean unwrapScriptObjects)
Creates a Variant object of type VT_EMPTY.
public Variant();
Creates a Variant object of type VT_I4.
public Variant(int val);
val | The initial value of the Variant object. |
Creates a Variant object of type VT_R8.
public Variant(double val);
val | The initial value of the Variant object. |
Creates a Variant object of type VT_BOOL.
public Variant(boolean val);
val | The initial value of the Variant object. |
Creates a Variant object of type VT_BSTR.
public Variant(String val);
val | The initial value of the Variant object. |
Creates a Variant object of type VT_ARRAY or VT_BYREF|VT_ARRAY. Typically, fByRef is set to true when you create a Variant object to pass as a parameter, and it is false when you create a Variant object that is used as a return value.
public Variant(SafeArray val, boolean fByRef);
val | The initial SafeArray value. |
fByRef | Indicates how to set the VT_BYREF modifier. |
If fByRef is true, any changes made to the SAFEARRAY data structure through the new Variant object will be visible to the SafeArray instance used to initialize the Variant object.
If fByRef is false, the method revokes the SafeArray instance's ownership. Any further operations on that instance will throw an exception. This is because ownership of the SAFEARRAY data structure has been transferred to the new Variant object. To retrieve any changes made through the Variant object, you must call the toSafeArray method to obtain a new proxy.
Creates a Variant object of type VT_DISPATCH or VT_BYREF|VT_ARRAY.
public Variant(Object value);
If the argument is a Java SafeArray object, this constructor is equivalent to the following code:
Variant(value, true)
Otherwise, this constructor creates a VT_DISPATCH.
value | The initial value. |
Creates a Variant object of the type indicated by vartype. The type can be VariantShort, VariantInt, or VariantByte. The VariantByref modifier can be set on any of these types.
public Variant(int vartype, int val);
vartype | The variant type. |
val | The initial value. |
Creates a Variant object of the type indicated by vartype. The type can be VariantBoolean, or VariantByref|VariantBoolean.
public Variant(int vartype, boolean val);
vartype | The variant type. |
val | The initial value. |
Creates a Variant object of the type indicated by vartype. The type can be VariantDouble, VariantFloat, or VariantDate. The VariantByref modifier can be set on any of these types.
public Variant(int vartype, double val);
vartype | The variant type. |
val | The initial value. |
Creates a Variant object of the type indicated by vartype. The type can be VariantString, VariantObject, or VariantDispatch. The VariantByref modifier can be set on any of these types.
public Variant(int vartype, Object val);
vartype | The variant type. |
val | The initial value. |
If unwrapScriptObjects is set to true, this constructor creates an object of the type indicated by value, which can be types VT_BOOL, VT_BSTR, or VT_R8. Otherwise, this constructor creates a VT_DISPATCH.
public Variant(Object value, boolean unwrapScriptObjects);
value | The initial value. |
unwrapScriptObjects | Indicates whether script objects are to be unwrapped. |
This constructor was added as of versions 2437 through 2925 of the Microsoft virtual machine.