Information.VarType(Object) Metodo

Definizione

Restituisce un Integer valore contenente la classificazione del tipo di dati di una variabile.

public:
 static Microsoft::VisualBasic::VariantType VarType(System::Object ^ VarName);
public static Microsoft.VisualBasic.VariantType VarType(object VarName);
static member VarType : obj -> Microsoft.VisualBasic.VariantType
Public Function VarType (VarName As Object) As VariantType

Parametri

VarName
Object

Required. Object Variabile. Se Option Strict è Off, è possibile passare una variabile di qualsiasi tipo di dati, ad eccezione di una struttura.

Valori restituiti

Restituisce un Integer valore contenente la classificazione del tipo di dati di una variabile.

Esempio

Nell'esempio seguente viene utilizzata la VarType funzione per restituire informazioni sulla classificazione dei tipi di dati relative a diverse variabili.

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.

Commenti

Il valore intero restituito da VarType è un membro dell'oggetto VariantType.

Nella tabella seguente vengono illustrati i valori restituiti da VarType per casi speciali di VarName.

Tipo di dati rappresentato da VarName Valore restituito da VarType
Niente VariantType.Object
DBNull VariantType.Null
Enumeration Tipo di dati sottostante (SByte, Byte, ShortUShort, Integer, UInteger, Longo ULong)
Array OR bit per bit del tipo di elemento della matrice e VariantType.Array
Matrice di matrici OR bit per bit di VariantType.Object e VariantType.Array
Struttura (System.ValueType) VariantType.UserDefinedType
Exception VariantType.Error
Sconosciuto VariantType.Object

Si applica a

Vedi anche