- Integer %
- Long &
- Currency @
- Single !
- Double #
- String $
See example below, which are basically the same.
Sub Sample1()
Dim a#
a = 1.2
Debug.Print a
End Sub
Sub Sample2()
Dim a As Double
a = 1.2
Debug.Print a
End Sub
Consider this two procedures below:
Sub Sample1()
Dim a As Double, b As Integer
b = 32767
a = b * 100
Debug.Print a
End Sub
Sub Sample2()
Dim a As Double, b As Integer
b = 32767
a = b * 100#
Debug.Print a
End Sub
Question: One of them will fail. Can you guess which one?Ans: The 1st procedure
Sub Sample1() will fail.Reason:
In
Sample2, when you do b * 100# the result of calculation will be of type Double. Since it is within the limits of Double, so the calculation succeeds and the result is assigned to variable a.Now in
Sample1, when you do b * 100 the result of calculation will be of type Integer,
since both the operands are of type integer. But the result of
calculation exceeds the limits of Integer storage. As a result it will
error out.