Data Types

A Data Type refers to how the data is stored in memory and how many bytes that data needs.
You should always try and use the data type that uses the smallest number of bytes.
The default value for all the number data types is zero.

Byte (0 to 255)(by) very small integers, use Long instead
1 byte (8 bits)
Conversion - CByte
Integer (- 32,768 to + 32,767)(i) small integers, use Long instead
2 bytes (16 bits)
Conversion - CInt, Declaration Character - %
Long (- 2.1 E+9 to + 2.1 E+9)(l) very large integers
4 bytes (32 bits)
Conversion - CLng, Declaration Character - &
Single (- 1.3 E+38 to + 1.3 E+38)(sg) single precision floating point for decimals, use Double instead
4 bytes (32 bits)
Conversion - CSng, Declaration Character - !
Double (- 1.8 E+308 to + 4.9 E+324)(db) double precision floating point for decimals
8 bytes (64 bits)
Conversion - CDbl, Declaration Character - #
Currency (- 9.2 E+14 to + 9.2 E+14)(c) scaled integer, use Double instead
8 bytes (64 bits)
Conversion - CCur, Declaration Character - @
Decimal* (- 7.9 E+28 to + 7.9 E+28)(dv) Variant subtype
Must be declared as a Variant and then converted using the CDec function
14 bytes (112 bits)
Conversion - CDec
LongLong(ll) Added in Office 2010, VBA 7.0
Conversion - CLngLng, Declaration Character - ^
LongPtr(lp) Added in Office 2010, VBA 7.0
LongLong on 64 bit, Long on 32 bit
Conversion - CLngPtr
Byte (0 to 255)
(by) very small integers, use Long instead
1 byte (8 bits)
Conversion - CByte
Integer (- 32,768 to + 32,767)
(i) small integers, use Long instead
2 bytes (16 bits)
Conversion - CInt, Declaration Character - %
Long (- 2.1 E+9 to + 2.1 E+9)
(l) very large integers
4 bytes (32 bits)
Conversion - CLng, Declaration Character - &
Single (- 1.3 E+38 to + 1.3 E+38)
(sg) single precision floating point for decimals, use Double instead
4 bytes (32 bits)
Conversion - CSng, Declaration Character - !
Double (- 1.8 E+308 to + 4.9 E+324)
(db) double precision floating point for decimals
8 bytes (64 bits)
Conversion - CDbl, Declaration Character - #
Currency (- 9.2 E+14 to + 9.2 E+14)
(c) scaled integer, use Double instead
8 bytes (64 bits)
Conversion - CCur, Declaration Character - @
Decimal* (- 7.9 E+28 to + 7.9 E+28)
(dv) Variant subtype
Must be declared as a Variant and then converted using the CDec function
14 bytes (112 bits)
Conversion - CDec
LongLong
(ll) Added in Office 2010, VBA 7.0
Conversion - CLngLng, Declaration Character - ^
LongPtr
(lp) Added in Office 2010, VBA 7.0
LongLong on 64 bit, Long on 32 bit
Conversion - CLngPtr

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext