Visual Basic Data types

Data is information that will be processed by your application, and broadly speaking can be categorised as being numeric, character-based (i.e. alpha-numeric characters or strings) or a collection of attributes that represent various kinds of object.

Variables are memory locations that hold the data values assigned to them at any given time. Each variable has a name, an address in memory, and a size (usually measured in bytes) that determines the amount of memory it occupies. The variable's size is dependent on its data type. The size of a standard ASCII character variable, for example, is 1 byte.

The table below lists the numeric data types supported by Visual Basic.



Visual Basic Numeric Data Types
TypeBitsDescriptionMinMax
Byte8Unsigned integer0255
SByte8Signed integer-128127
Short16Signed (short) integer-32,76832,767
UShort16Unsigned (short) integer065,535
Integer32Signed integer-2,147,483,6482,147,483,647
UInteger32Unsigned integer04,294,967,295
Long64Signed (long) integer-9,223,372,036,854,775,8089,223,372,036,854,775,807
ULong64Unsigned (long) integer018,446,744,073,709,551,615
Single32Single-precision floating point number-3.4028235E383.4028235E38
Double64Double-precision floating point number-1.79769313486231E3081.79769313486231E308
Decimal128Decimal number *-7.92E+287.92E+28

* Values depend on whether or not a decimal point is used and if so how many places to the right of the decimal point (up to a maximum of 28) are used. For example, if all 28 places are used, the range of values that can be represented is -7.9228162514264337593543950335 to 7.9228162514264337593543950335.

The table below lists some of the non-numeric data types supported by Visual Basic.



Visual Basic Non-numeric Data Types
TypeDescription
BooleanA data type that can only evaluate to True (non-zero) or False (zero).
CharA Unicode character code in the range 0 to 65,535.
StringA sequence of zero or more unsigned 16-bit code points (character codes) that can range in value from 0 to 65535. Each code point represents a single Unicode character. A string can contain from zero to approximately two billion (231) Unicode characters.
DateCan hold 64-bit DateTime values in the range 0:00:00, January 1 of the year 0001 to 23:59:5999999, December 31 of the year 9999. Each increment represents 100 nanoseconds of elapsed time since the beginning of January 1 of the year 1 in the Gregorian calendar. The maximum value represents 100 nanoseconds before the beginning of January 1 of the year 10000.
ObjectA variable of type object can store any data type. Objects are referenced using 32-bit pointer variable or or a 64-bit pointer variable, depending on whether the code is running on a 32-bit or a 64-bit platform.