VARTYPE() Function Returns Value 8204 for Variant/Array |
Q131336
In 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:
When 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.
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 Sub
Even 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.
Dim x(3) As Variant
For more information about the VarType Function, choose the Search button in Visual Basic Reference Help, and type:
VarType
Additional query words:
Keywords :
Issue type :
Technology : kbHWMAC kbOSMAC kbExcelSearch kbZNotKeyword6 kbExcel500 kbProjectSearch kbProject400Mac kbExcelMacsearch kbProjectMacSearch kbVBASearch kbZNotKeyword3 kbExcel500Mac kbExcel500aMac kbExcel500c kbProject400 kbVBA100
|
Last Reviewed: January 17, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |