Information.VarType(Object) Método
Definição
Retorna um valor Integer que contém a classificação de tipo de dados de uma variável.Returns an Integer value containing the data type classification of a variable.
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
Parâmetros
- VarName
- Object
Obrigatórios.Required. Variável Object.Object variable. Se Option Strict for Off, você poderá passar uma variável de qualquer tipo de dados, exceto uma estrutura.If Option Strict is Off, you can pass a variable of any data type except a structure.
Retornos
Retorna um valor Integer que contém a classificação de tipo de dados de uma variável.Returns an Integer value containing the data type classification of a variable.
Exemplos
O exemplo a seguir usa a VarType função para retornar informações de classificação de tipo de dados sobre várias variáveis.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.
Comentários
O valor inteiro retornado por VarType é um membro do VariantType .The integer value returned by VarType is a member of the VariantType.
A tabela a seguir mostra os valores retornados pelo VarType para casos especiais do VarName .The following table shows the values returned by VarType for special cases of VarName.
Tipo de dados representado por VarNameData type represented by VarName |
Valor retornado por VarTypeValue returned by VarType |
|---|---|
| NothingNothing | VariantType.Object |
| DBNull | VariantType.Null |
| EnumeraçãoEnumeration | Tipo de dados subjacente ( SByte ,,,,,, Byte Short UShort Integer UInteger Long ou ULong )Underlying data type (SByte, Byte, Short, UShort, Integer, UInteger, Long, or ULong) |
| ArrayArray | Tipo de elemento de matriz or VariantType.ArrayBitwise OR of array element type and VariantType.Array |
| Matriz de matrizesArray of arrays | Or VariantType.Object``VariantType.ArrayBitwise OR of VariantType.Object and VariantType.Array |
| Estrutura ( System.ValueType )Structure (System.ValueType) | VariantType.UserDefinedType |
| Exception | VariantType.Error |
| UnknownUnknown | VariantType.Object |