ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   When does TRUE evaluate to minus 1? (https://www.excelbanter.com/excel-programming/335676-when-does-true-evaluate-minus-1-a.html)

davidm

When does TRUE evaluate to minus 1?
 

I want to exploit the fact TRUE equtes to -1 but cannot get my hea
around the conditions surrounding this. I have experimented in cod
with MsgBox (5=(50/10)) , or some such direct equality , but each tim
simply get the result TRUE.

How can I wrest *minus 1* from a TRUE boolean relationship

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=39060


TommySzalapski[_17_]

When does TRUE evaluate to minus 1?
 

Convert the bool to and integer

CInt(True) = -1

CInt(5=5) = -1

CInt(5=4) =

--
TommySzalapsk
-----------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...fo&userid=2556
View this thread: http://www.excelforum.com/showthread.php?threadid=39060


davidm

When does TRUE evaluate to minus 1?
 

Thanks Tommy. Exactly what I am lookoing for

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=39060


Tom Ogilvy

When does TRUE evaluate to minus 1?
 
msgbox "the column is " & _
Left(ActiveCell.Address(0,0), 2 + (ActiveCell.column < 27))

would be an example of exploiting True is equivalent to -1

--
Regards,
Tom Ogilvy

"davidm" wrote in
message ...

I want to exploit the fact TRUE equtes to -1 but cannot get my head
around the conditions surrounding this. I have experimented in code
with MsgBox (5=(50/10)) , or some such direct equality , but each time
simply get the result TRUE.

How can I wrest *minus 1* from a TRUE boolean relationship?


--
davidm
------------------------------------------------------------------------
davidm's Profile:

http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=390606




Chip Pearson

When does TRUE evaluate to minus 1?
 
You can either use CInt to convert it to an integer, or do some
arithmetic with it. E.g.

Dim Res As Integer
Res = CInt(5 = (50 / 10))
Debug.Print Res
' or
Res = (5 = (50 / 10)) + 0
Debug.Print Res


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"davidm"
wrote in message
...

I want to exploit the fact TRUE equtes to -1 but cannot get my
head
around the conditions surrounding this. I have experimented in
code
with MsgBox (5=(50/10)) , or some such direct equality , but
each time
simply get the result TRUE.

How can I wrest *minus 1* from a TRUE boolean relationship?


--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread:
http://www.excelforum.com/showthread...hreadid=390606





All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com