The Variant variable has an OLE definition that can be stored any type of data, and some variables are stored in 16 bytes in the format of the figure below.
0-1 2-7 8-15 VARTYPE Unused Value
The 0th and 1-byte saves an integer value to indicate what type of data stored in the 8-15 byte, and the 2nd to 7 bytes are generally useless, and in most cases, The 8th to 15th bytes of the variable are not all used. Such as: Save an integer number with a Variant variable, then start the value of 2-Vbinteger, sessiles 8 and 9 bytes in the two bytes.
Let's write a code to verify it.
DIM V AS VARIANT 'VARIANT is the default data type of VB, so it can also be defined as DIM V
v = 1000
Debug.print Vartype (V) 'Output Results 2 -VBINTEGER
Also replace it:
Private Declare Sub CopyMemory LIB "kernel32" Alias "RTLMoveMemory" (Destination As Any, Source As Any, BYVAL LENGTH AS "
DIM V As Variant
DIM I as integer
v = 1000
CopyMemory I, V, 2
Debug.print "0-1" is "& I
CopyMemory I, Byval (Varptr (V) 8), 2
Debug.print "8-9 is" & i
It can be seen that the result of 8-9 bits is 1000, while 0-1 bit is 2-vbinteger.