- Mar 4, 2005
I have noticed that boolean is not strictly enforced in VBA. And that the byte datatype is takes half the memory. I have run some tests and have noticed that you can a booean true into byte and get 255 and boolean false and get 0. I have also noticed that if you evaluate byte like it's boolean it will be read false if it 0 and true if it is any other number. Given that the data types seem to be fully interchangable... why would you even want to use boolean? Is there any downside to just using byte in all cases?
Boolean Data Type Boolean variables are stored as 16-bit (2-byte) numbers, but they can only be True or False. Boolean variables display as either True or False (when Print is used) or #TRUE# or #FALSE# (when Write # is used). Use the keywords True and False to assign one of the two states to Boolean variables. When other numeric types are converted to Boolean values, 0 becomes False and all other values become True. When Boolean values are converted to other data types, False becomes 0 and True becomes -1. Byte Data Type Byte variables are stored as single, unsigned, 8-bit (1-byte) numbers ranging in value from 0–255. The Byte data type is useful for containing binary data.