View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
RichardSchollar[_2_] RichardSchollar[_2_] is offline
external usenet poster
 
Posts: 76
Default Did you know that...

Hi Darek

Byte in VBA is an unsigned data-type, so I presume it could never have
returned -1. I definitely agree with your closing comments though :-D

Best regards

Richard


On 27 Feb, 13:00, "darlove" wrote:
... that when you execute CByte(True) you will get... 255(!!!) instead
of -1??? I have discovered this by chance when I was writing code like
this:

aByteVariable = aByteVariable -
CByte(aFunctionThatReturnsBoolean(anArgument) )

to get rid of the If-Then-Else clause. Thank God I was using a byte
variable and got an overflow error
for if I had used a long variable, I would probably never have
discovered the cause of the error...
Well, I'd have eventually but it would have taken more time, I
presume.

Darek
ps. Always step through your code line by line and check (almost)
every possible scenario.
If you do not do this, you can be very much taken by surprise :)