Share via


Funzione VarType (Visual Basic)

Aggiornamento: novembre 2007

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

Public Function VarType(ByVal VarName As Object) As VariantType

Parametri

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

Note

Il valore integer restituito da VarType è un membro dell'Enumerazione VariantType.

Nella tabella riportata di seguito vengono illustrati i valori restituiti da VarType per casi specifici di VarName.

Tipo di dati rappresentato da VarName

Valore restituito da VarType

Nothing (Visual Basic)

VariantType.Object

DBNull

VariantType.Null

Enumerazione

Tipo di dati sottostante (SByte, Byte, Short, UShort, Integer, UInteger, Long o ULong)

Matrice

Operatore OR bit per bit del tipo di elemento di matrice e VariantType.Array

Matrice di matrici

Operatore OR bit per bit di VariantType.Object e VariantType.Array

Struttura (System.ValueType)

VariantType.UserDefinedType

Exception

VariantType.Error

Sconosciuto

VariantType.Object

Esempio

Nell'esempio riportato di seguito la funzione VarType viene utilizzata per restituire informazioni sulla classificazione del tipo di dati di 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.

Note per gli sviluppatori di applicazioni per Smart Device

Questa funzione non è supportata.

Requisiti

Spazio dei nomi: Microsoft.VisualBasic

Modulo: Information

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Vedere anche

Riferimenti

Riepilogo dei tipi di dati (Visual Basic)

Tipo di dati Object

Enumerazione VariantType