2.1 Data Values and Value Types

 Within a VBA Environment, information is represented as data values. A data value is a single element from a specific finite domain of such elements. The VBA Environment defines a variety of value types. These value types collectively define the domain of VBA data values. Each value type has unique characteristics that are defined by this specification. Each data value within a VBA Environment is a domain member of one of these value types. Individual data values are immutable. This means that there are no defined mechanisms available within a VBA Environment that can cause a data value to change into another data value. Because data values are immutable, multiple copies of a specific data value can exist within a VBA Environment and all such copies are logically the same data value.

The value types of the VBA Environment are defined by the following table. The nominal representation is the representation that was used as the original design basis for the VBA value types.

Implementations can use these specific data type representations to meet the requirements of this specification.

Value Type Name

Domain Elements

Nominal Representation

Boolean

The distinguished values True and False

16-bit signed binary 2’s complement integer whose

value is either 0 (False) or -1 (True)

Byte

Mathematical integer in the range of 0 to 255

8-bit unsigned binary integer

Currency

Numbers with 4 fractional decimal digits in the range

-922,337,203,685,477.5808 to

+922,337,203,685,477.5807

64-bit signed binary two’s complement integer

implicitly scaled by 10-4

Date

Ordinal fractional day between the first day of the year 100 and the last day of the year 9999.

8 byte IEEE 754-1985

[IEEE754] floating point value. The floating point value 0.0 represents the epoch date/time which is midnight of December 30, 1899. Other dates are represented as a number of days before (negative values) or after (positive value) the epoch. Fractional values represent fractional days.

Decimal

Scaled integer numbers whose maximum integer range is

±79,228,162,514,264,337,593,543,950,335.

Number in this range MAY be scaled by powers of ten in the range 100 to 10-28

A rational number represented in a 14 byte data structure including a sign bit and a 96-bit unsigned integer numerator. The denominator is an integral power of ten with an exponent in the range of 0 to 28 encoded in a single byte.

Double

All valid IEEE 754-1985 double-precision binary floating-point numbers including sized zeros, NaNs and infinities

64-bit hardware implementation of IEEE 7541985.

Integer

Integer numbers in the range of -32,768 to 32,767

16-bit binary two’s complement integers

Long

Integer numbers in the range of -2,147,483,648 to 2,147,486,647

32-bit binary two’s complement integers

LongLong

Integer numbers in the range of

-9,223,372,036,854,775,808 to

9,223,372,036,854,775,807

64-bit binary two’s complement integers

Object reference

Unique identifiers of host application or program created objects and a distinguished value corresponding to the reserved identifier Nothing

Machine memory addresses with the 0 address reserved to represent Nothing.

Single

All valid IEEE 754-1985 single-precision binary floating-point numbers including signed zeros, NaNs and infinities

32-bit hardware implementation of IEEE 7541985.

String (variable length)

The zero length empty string and all possible character sequences using characters from the implementation dependent character set. There MAY be an implementation defined limit to the length of such sequences but the limit SHOULD be no more than (216 – 10) characters.

Sequences of 16-bit binary encoded Unicode code points.

String*n

(fixed-length)

The length of string is between 1 to 65,526.

1 to approximately 64K (216 – 10) characters.

Empty

A single distinguished value corresponding to the reserved identifier Empty

An implementation-specific bit pattern

Error

Standard error codes from 0 to 65535, as well as other implementation-defined error values. An implementation-defined error value can resolve to a standard error code from 0 to 65535 in a context where its value is required, such as CInt.

32-bit integer (Windows

HRESULT)

Null

A single distinguished value corresponding to the reserved identifier Null

An implementation specific bit pattern

Missing

A single distinguished value corresponding that is used to indicated that no value was passed corresponding to an explicitly declared optional parameter.

An implementation specific bit pattern

An Array type

Multi-dimensional numerically indexed aggregations of data values with up to 60 dimensions. Empty aggregations with no dimensions are also included in the domain. Such aggregations can be homogeneous (all elements (section 2.1.1) of the aggregation have the same value type) or heterogeneous (the value types of elements are unrelated). Elements of each dimension are identified (indexed) via a continuous sequence of signed integers. The smallest index value of a dimension is the dimension’s lower bound and the largest index value of a dimension is the dimension’s upper bound. A lower bound and an upper bound might be equal.

A linear concatenation of the aggregated data values arranged in row major order

possibly with implementation defined padding between individual data values.

A User-Defined Type (UDT)

Aggregations of named data values with possibly heterogeneous value types. Each UDT data value is associated with a specific named UDT declaration which serves as its value type.

A linear concatenation of the aggregated data values possibly with implementation defined padding between data values.

 

The VBA language also provides syntax for defining what appears to be an additional kind of data type known as an Enum. There is no Enum-specific value type. Instead, Enum members are represented as Long data values.

An implementation of VBA MAY include for other implementation-defined value types which can be retrieved as return values from procedures in referenced libraries. The semantics of such data values when used in statements and expressions within the VBA Environment are implementation-defined.