contents   index   previous   next



Clearing Variants

 

It is always a good practice to make sure that memory used by a Variant is released before your program leaves the scope where the Variant is defined. This is particularly important in the cases of Variants containing BStrings, Safe Arrays or references to objects. Otherwise you may be risking memory leaks. Use subroutine VariantClear to release the memory used by a Variant variable. When you call VariantClear passing a Variant that contains a Safe Array or a BString, f90VB calls the appropriate system APIs to release the memory used by the Safe Array or the BString. If the Variant contains a reference to an object’s interface (i.e. it has a VT-Type of VT_UNKNOWN or VT_DISPATCH), then f90VB will call the Release method of the interface. In addition, VariantClear sets the vt field of the array to VT_EMPTY. Example 3.2 shows how to call VariantClear.

 

Variant arithmetic and logical operations