I tried using #define to name all the bits and the using a #define for a mask. This works.
The other way is to use a Const for each bit of the byte. It also works.
Does a #Define use more or less memory than a Const?
Is a #Define faster than a Const?
Which way is better?
Example: using #Define
Code: Select all
'using #define
#Define Bit1 1
#Define Bit2 2
#Define Bit3 4
#Define Bit4 8
#Define Bit5 16
#Define Bit6 32
#Define Bit7 64
#Define Bit8 128
'other bytes currently not being used but can easily be expanded in the future
'create a mask. Others can easily be made.
#Define ComboBits Bit1+Bit2+Bit3
Dim ColorByte as UInteger
ColorByte = (ColorByte and ComboBits) 'isolate the first 3 bits.
end
Code: Select all
'using Const
Const Bit1 1
Const Bit2 2
Const Bit3 4
Const Bit4 8
Const Bit5 16
Const Bit6 32
Const Bit7 64
Const Bit8 128
'other bytes currently not being used but can easily be expanded in the future
'create a mask. Others can easily be made.
Const ComboBits Bit1+Bit2+Bit3
Dim ColorByte as UInteger
ColorByte = (ColorByte and ComboBits) 'isolate the first 3 bits.
end