Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default True and True

Hi

pl can someone explain why the ansers are negative in the extract from the
Immediate box

thanks

Tim

?true + true

-2



? True + TRUE

-2



?true + false

-1



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default True and True

Hi Tim
in VBA TRUE evaluates to -1 (opposed to 1 in Excel formulas)
so in your case TRUE + TRUE = (-1) + (-1) = -2 and TRUE + FALSE = (-1)
+ 0 = -1

HTH
Frank

Tim Childs wrote:
Hi

pl can someone explain why the ansers are negative in the extract
from the Immediate box

thanks

Tim

?true + true

-2



? True + TRUE

-2



?true + false

-1



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default True and True

Frank

many thanks - it seems bizarre on the one hand but it certainly explains the
responses in the Immediate window

regards

Tim


"Frank Kabel" wrote in message
...
Hi Tim
in VBA TRUE evaluates to -1 (opposed to 1 in Excel formulas)
so in your case TRUE + TRUE = (-1) + (-1) = -2 and TRUE + FALSE = (-1)
+ 0 = -1

HTH
Frank




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default True and True

Hi Tim

That's because contrary to TRUE in Excel,
which is 1, TRUE in VBA is -1

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Tim Childs" skrev i en meddelelse
...
Hi

pl can someone explain why the ansers are negative in the extract from the
Immediate box

thanks

Tim

?true + true

-2



? True + TRUE

-2



?true + false

-1





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default True and True

Tim,

False is 0
True is actually better thought of as NOT 0.
In 8 bit binary:
00000000 = False
11111111 = True

If that binary number for True is represented as a signed byte, it turns out
to be -1


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Tim Childs" wrote in message
...
Hi

pl can someone explain why the ansers are negative in the extract from the
Immediate box

thanks

Tim

?true + true

-2



? True + TRUE

-2



?true + false

-1







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if any of 3 conditions is true, then answer is true inthestands Excel Worksheet Functions 5 November 16th 06 12:02 AM
Search for 2 true arguments and return true or false David Excel Discussion (Misc queries) 3 July 15th 06 10:18 AM
Function to return True/False if all are validated as True by ISNU Tetsuya Oguma Excel Worksheet Functions 2 March 15th 06 10:28 AM
How do I stop Excel from changing the word true to TRUE? Schmyerlou Excel Discussion (Misc queries) 1 November 23rd 05 08:54 PM
Reverse false and combine with true true value Emmie99 Excel Worksheet Functions 5 August 17th 05 04:38 PM


All times are GMT +1. The time now is 07:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"