Data Types

Whether VB is a weakly or a semi-strongly typed language depends on the Option Explicit setting. (The statement must appear at the top of a code module.) If Off, VB is a weakly typed language; variables need not be declared in advance, and all undeclared variables will be cast as type Object until they are initialized. If On (its default setting), each variable must be declared in advance, but its data type need not be specified. If no type is explicitly declared, variables are cast as type Object until their first use.

Although VB recognizes a number of “intrinsic” data types, each is really a wrapper around a data type found in the .NET Common Type System (CTS). VB recognizes the following intrinsic types:

Boolean

A logical (True or False) value. Corresponds to System.Boolean.

Byte

A signed 8-bit numeric data type. Corresponds to System.Byte.

Char

A 16-bit character data type (character code). Corresponds to System.Char.

Date

A date or time value. Corresponds to System.DataTime.

Decimal

A decimal or currency value. Corresponds to System.Decimal.

Double

A double-precision floating point value. Corresponds to System.Double.

Integer

A signed 32-bit integral data type. Corresponds to System.Int32.

Long

A signed 64-bit integral data type. Corresponds to System.Int64.

Object

A reference to an object. Object is VB’s “universal” data type and corresponds to System.Object.

Short

A signed 16-bit integral data type. Corresponds to System.Int16.

Single

A single-precision floating point value. ...

Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.