Skip to Content
VB .NET Language in a Nutshell
book

VB .NET Language in a Nutshell

by Steven Roman PhD, Ron Petrusha, Paul Lomax
August 2001
Intermediate to advanced
656 pages
18h 5m
English
O'Reilly Media, Inc.
Content preview from VB .NET Language in a Nutshell

Name

VarType Function

Class

Microsoft.VisualBasic.Information

Syntax

VarType(varname)
varname

Use: Required

Data Type: Any

The name of a variable

Return Value

A member of the VariantType enumeration indicating the variable type

Description

Determines the data type of a variable

Rules at a Glance

  • The possible values returned by the function include the following members of the VariantType enumeration.

    Constant

    Value

    Description

    Array

    8192

    Array

    Boolean

    11

    Boolean data type

    Byte

    17

    Byte data type

    Char

    18

    Char data type

    Date

    7

    Date data type

    Decimal

    14

    Decimal data type

    Double

    5

    Double data type

    Integer

    3

    Integer data type

    Long

    20

    Long data type

    Object

    9

    Object, uninitialized string, uninitialized array, object of a specific type

    Short

    2

    Short data type

    Single

    4

    Single data type

    String

    8

    String

    UserDefinedType

    36

    A structure

  • If varname is a dimensioned array, the VarType function returns VariantType.Array (8192), plus the value of the array’s data type. For example, an array of strings returns 8192 + 8 = 8200. You can test for an array with a code fragment such as the following:

    If VarType(myVar) And VariantType.Array Then
  • You can extract the data type of the array with the following code fragment:

    vartype(myVar) and &HFFFFDFFF
  • All object variables, whether late-bound or early-bound, return VariantType.Object.

  • Data types that are members of the base class library but are not wrapped by VB data types (i.e., UINT16, UINT32, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

VB & VBA in a Nutshell: The Language

VB & VBA in a Nutshell: The Language

Paul Lomax
VB.NET Language in a Nutshell, Second Edition

VB.NET Language in a Nutshell, Second Edition

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596000928Catalog PageErrata