Internal Structure

A Variant always takes up at least 16 bytes of memory and is structured as shown in Figure 4-1.

Figure 4-1 The structure of a Variant

The first two bytes correspond to the value returned by the VarType function. (The VarType return values are defined as constants in the VbVarType enumeration.) For example, if the VarType is 2 (the value of the constant vbInteger), the Variant has a subtype of Integer. You cannot change this value directly, but the conversion functions (such as CInt) will do this for you.

The Reserved bytes have no documented function yet; their principal purpose is to pad the structure out to 16 bytes. The Data area holds the value of the variable, if the value fits into 8 bytes; otherwise, the Data area holds a pointer to the data (as with strings and so on). The type indicates how the Data portion of the Variant is to be understood or interpreted.

In this way, Variants are self-describing, meaning they contain within them all the information necessary to use them.



Ltd Mandelbrot Set International Advanced Microsoft Visual Basics 6. 0
Advanced Microsoft Visual Basic (Mps)
ISBN: 1572318937
EAN: 2147483647
Year: 1997
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net