Information.VarType(Object) Método
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Retorna um valor Integer
que contém a classificação de tipo de dados de uma variável.
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
- VarName
- Object
Obrigatórios. Variável Object
. Se Option Strict
for Off
, você poderá passar uma variável de qualquer tipo de dados, exceto uma estrutura.
Retorna um valor Integer
que contém a classificação de tipo de dados de uma variável.
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.
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.
O valor inteiro retornado por VarType
é um membro do VariantType.
A tabela a seguir mostra os valores retornados por VarType
para casos especiais de VarName
.
Tipo de dados representado por VarName |
Valor retornado por VarType |
---|---|
Nothing | VariantType.Object |
DBNull | VariantType.Null |
Enumeração | Tipo de dados subjacente (SByte , Byte , , Short UShort , Integer , UInteger , Long ou ULong ) |
Array | OR bit a bit do tipo de elemento de matriz e VariantType.Array |
Matriz de matrizes | OR bit a bit de VariantType.Object e VariantType.Array |
Estrutura (System.ValueType) | VariantType.UserDefinedType |
Exception | VariantType.Error |
Unknown | VariantType.Object |
Produto | Versões |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Comentários do .NET
O .NET é um projeto código aberto. Selecione um link para fornecer comentários: