This documentation is archived and is not being maintained.

Information.VarType Method

Returns an Integer value containing the data type classification of a variable.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static VariantType VarType(
	Object VarName


Type: System.Object
Required. Object variable. If Option Strict is Off, you can pass a variable of any data type except a structure.

Return Value

Type: Microsoft.VisualBasic.VariantType
Returns an Integer value containing the data type classification of a variable.

The integer value returned by VarType is a member of the VariantType.

The following table shows the values returned by VarType for special cases of VarName.

Data type represented by VarName

Value returned by VarType

Nothing (Visual Basic)





Underlying data type (SByte, Byte, Short, UShort, Integer, UInteger, Long, or ULong)


Bitwise OR of array element type and VariantType.Array

Array of arrays

Bitwise OR of VariantType.Object and VariantType.Array

Structure (System.ValueType)






The following example uses the VarType function to return data type classification information about several variables.

Dim testString As String = "String for testing"
Dim testObject As New Object
Dim testNumber, testArray(5) As Integer
Dim testVarType As VariantType
testVarType = VarType(testVarType)
' Returns VariantType.Integer.
testVarType = VarType(testString)
' Returns VariantType.String.
testVarType = VarType(testObject)
' Returns VariantType.Object.
testVarType = VarType(testNumber)
' Returns VariantType.Integer.
testVarType = VarType(testArray)
' Returns the bitwise OR of VariantType.Array and VariantType.Integer.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.