MLH wrote:
?2944*24
gives me an overflow error, entered in the
immediate window. Anybody else?
VBA is an archaic, inefficient language which sometimes treats literals
inefficiently.
In this case it looks at 2944 and say ... "integer" so
I should try to put 2944 into an integer.
It can't so it reports an overflow.
Dim l As Long
l = 2944
Debug.Print l * 24
This works fine because VBA recognizes l as a long.
It may be helpful to declare all variables and forget literals. I never
use the immediate window (except for debug.print) and am astounded by
the many posts which recommend it.
BTW, this accounts for the nonsense that True=-1.
When we make all the bits in an integer zero we get zero. This is false.
(All the flags are down)
When we do NOT to all those bits we change them all to 1's.
(All the flags are up)
And of course all ones is -1 (twos complement).
So, first VBA decides to treat True as an integer. Because it doesn't
have an unsigned integer it uses a signed integer. Arggggggggggggh.
255 (byte) is, in my opinion a much better numerical equivalent for
true. As a byte is not signed, we don't have the -1 absurdity.
Dim b As Byte
b = True
Debug.Print b '255
--
--
Lyle
"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet