Information.VarType(Object) Metodo

Definizione

Restituisce un valore Integer 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);
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

Obbligatorio. Variabile Object. Se Option Strict è Off, è possibile passare una variabile di qualsiasi tipo di dati tranne una struttura.

Restituisce

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

Esempio

Nell'esempio seguente viene usata la VarType funzione per restituire informazioni sulla classificazione dei tipi di dati su 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.

La tabella seguente mostra i valori restituiti da VarType per casi speciali di VarName.

Tipo di dati rappresentato da VarName Valore restituito da VarType
Nothing VariantType.Object
DBNull VariantType.Null
Enumerazione Tipo di dati sottostante (SByte, UShortIntegerShortUIntegerByte, Longo )ULong
Array OR bit per bit del tipo di elemento 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