VARTYPE() Function Returns Value 8204 for Variant/ArrayLast reviewed: July 29, 1997Article ID: Q131336 |
The information in this article applies to:
SUMMARYIn Microsoft Visual Basic Programming System, Applications Edition, when you use the VarType function to return the value indicating the subtype of a variable, the function returns the value 8204 if your variable is defined as either of the following:
MORE INFORMATIONWhen you use the VarType function to return the subtype of your variable, the function returns the value 8204 for a variable that is an array of type Variant (8192 for Array + 12 for Variant). If your variable is a Variant that contains an array, the function also returns the value 8204. An array of type Variant is exactly the same as a Variant that contains an array. The following Visual Basic example demonstrates this: Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.
Visual Basic ExampleThe following procedure shows that the variable q, defined as a variant containing an array of values, x, y, and z, is actually an array of variant data types.
Sub VarConArray() ' Dimension variables Dim x As Integer, y As Integer, z As Integer Dim q As Variant ' Set value of variable q equal to variant containing ' array of integer data type q = Array(x, y, z) MsgBox VarType(q) ' returns value 8204 MsgBox TypeName(q) ' returns value Variant() MsgBox TypeName(q(1)) ' returns value Integer ' assign first element in array to string value "test" q(1) = "test" MsgBox VarType(q) ' returns value 8204 MsgBox TypeName(q) ' returns value Variant() MsgBox TypeName(q(1)) ' returns value String End SubEven though each element of the array q is dimensioned as an Integer data type, you can assign the value of any of the elements to a String type variable without receiving an error message. Additionally, when you use the TypeName function to return the type of one of the elements of q, the value String is returned, instead of Integer. Therefore, when you dimension an array as Variant data type, each element of the array is Variant data type. That is, an array of variants is the same as an array dimensioned as Variant data type as in the following example:
Dim x(3) As Variant REFERENCESFor more information about the VarType Function, choose the Search button in Visual Basic Reference Help, and type:
VarType Keywords : kbcode kbprg Version : 1.00 | 1.00 Platform : MACINTOSH WINDOWS |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |