On my 32-Bit PC, running Office 2003 Excel VBA, the following code
Debug.Print ""
Debug.Print Hex(&HFF00000 And &HF00000)
Debug.Print Hex(&HFF0000 And &HF0000)
Debug.Print Hex(&HFF000 And &HF000)
Debug.Print Hex(&HFF00 And &HF00)
Debug.Print Hex(&HFF0 And &HF0)
Debug.Print Hex(&HFF And &HF)
gives the following Output
F00000
F0000
FF000 '<- Here's the Anomaly
F00
F0
F
This Only seems to occur with the Hex Value "F"; ie substitute all the "F"'s with any other Hex Digit and the Output will be as expected
Looks like some hangover from 16-Bit processing
My world has been shattered
I'm wondering if;
1) this really is an Anomaly (or am I going mad?)
if it is;
2) does it occur with other Office Versions
3) does it occur on 64-Bit PCs
4) what's the most elegant work-around
Any clues would be appreciated
For large hex numbers in VBA you need to append &
(the long type character) to ensure it gets stored correctly as a long.
E.g. try this
Debug.Print &HF000, &HF000&