User FAQs
If you have a question, please send it to us.
1) Should I use Integer or Long ?
There is no performance advantage to using Integer variables.
VBA converts all Integer values to Long values, even if they are declared with the data type Integer.
Using the Long data type might actually be slightly faster because there is no automatic conversion.
Dim iCounter As Integer
Dim lCounter As Long
2) Can you describe the Byte data type ?
The Byte data type is used to store positive integer numbers.
The range is 0 to 255.
The size of this data type is 1 byte (8 bits).
Dim myByte As Byte
myByte = 0
myByte = 255
3) Can you describe the Integer data type ?
The Integer data type is used to store integer numbers.
The range is -32,768 to 32,767.
The maximum value is (2^15) - 1 = 32767.
The size of this data type is 2 bytes (16 bits).
Dim myInteger As Integer
myInteger = -32768
myInteger = 32767
4) Can you describe the Long data type ?
The Long data type is used to store integer numbers.
The range is -2,147,483,648 to 2,147,483,647.
The maximum value is (2^31) - 1 = 2147483647.
The size of this data type is 4 bytes (32 bits).
Dim myLong As Long
myLong = -2147483648
myLong = 2147483647
5) Can you describe the Single data type ?
The Single data type is used to store single precision floating point real numbers.
This can hold large numbers but with very little precision up to 7 significant figures.
The smallest value is -3.402823 E+38.
The largest value is 3.402823 E+38.
The size of this data type is 4 bytes (32 bits).
Dim mySingle As Single
mySingle = -3.402823E+38
mySingle = 3.402823E+38
6) Can you describe the Double data type ?
The Double data type is used to store double precision floating point real numbers.
This can hold very large numbers with good precision up to 15 significant figures.
The smallest value is -1.79769313486231 E+308.
The largest value is 1.79769313486231 E+308.
The size of this data type is 8 bytes (64 bits).
Dim myDouble As Double
myDouble = -1.79769313486231E+308
myDouble = 1.79769313486231E+308
7) Can you describe how to create a Variant/Decimal data type ?
The Variant data type has a special sub type called Variant/Decimal that can hold very large numbers.
Dim myDecimal As Variant
myDecimal = CDec("36.78")
8) Can you describe the Currency data type ?
The Currency is used to store fixed point real numbers (and is faster than Single because it does not use the floating point processor). Avoid using floating-point data types.
This has 15 digits to the left of the decimal point and 4 digits to the right.
The smallest value is -922,337,203,685,477.
The largest value is 922,337,203,685,477.
The size of this data type is 8 bytes (64 bits).
Dim myCurrency As Currency
myCurrency = -922337203685447
myCurrency = 922337203685447
9) What is the difference between Fixed Point and Single/Double Floating Point ?
Both are represented in binary (base 2).
Floating point data types support fewer significant digits than fixed point data types (decimal) but can represent larger or smaller numbers.
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext