If I put 1 in A1, this
MsgBox Range("A1") = 1
equates to TRUE, and this
MsgBox 1 * (Range("A1") = 1)
equals -1, whereas I would have expected 1.
Has this always been the case, and I've only just noticed, or is something funny going on?
If I put 1 in A1, this
MsgBox Range("A1") = 1
equates to TRUE, and this
MsgBox 1 * (Range("A1") = 1)
equals -1, whereas I would have expected 1.
Has this always been the case, and I've only just noticed, or is something funny going on?
Re: True statements evaluating to -1
http://msdn.microsoft.com/en-u…500%28v=office.10%29.aspx
The Boolean data type is a special case of an integer data type. The Boolean data type can contain True or False; internally, VBA stores the value of True as -1, and the value of False as 0.
Re: True statements evaluating to -1
Thanks patel. I had always assumed True was 1. I wonder why it's -1.
Re: True statements evaluating to -1
In Excel true = 1 : =N(true) or =1*true
In VBA true = -1
Re: True statements evaluating to -1
OK, so it's just VBA, probably why I never noticed before. Thanks snb.
Don’t have an account yet? Register yourself now and be a part of our community!