Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
a + b + c = -1
-- Regards, Tom Ogilvy "Frederick Chow" wrote: Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If Not ((a And b) Or (a And c) Or (b And c)) Then
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Frederick Chow" wrote in message ... Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
VBA stores false as 0 and true as -1. You can declare an interger variable and set it to A+B+C if the result is -1 only one is true. -- Tony Green "Frederick Chow" wrote: Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fails on
a = False b = False c = False -- Regards, Tom Ogilvy "Bob Phillips" wrote: If Not ((a And b) Or (a And c) Or (b And c)) Then -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Frederick Chow" wrote in message ... Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Frederick Chow" wrote in message ... Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The one I didn't try - <g
-- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Tom Ogilvy" wrote in message ... Fails on a = False b = False c = False -- Regards, Tom Ogilvy "Bob Phillips" wrote: If Not ((a And b) Or (a And c) Or (b And c)) Then -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Frederick Chow" wrote in message ... Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Suppose I have three Boolean variables A, B and C. How can I test if there
is exactly one of them is true? A Xor B Xor C Would this idea work? bJustOne = (a Or b) Xor c -- HTH. :) Dana DeLouis Windows XP, Office 2003 "Frederick Chow" wrote in message ... Hi all, Sorry first that my question may not be specifically related to Excel VBA, but I really encountered it when I had to write a VBA function. Suppose I have three boolean variables A, B and C. How can I test if there is exactly one of them is true? I found that the following expression A Xor B Xor C failed when A = True and B = True and C = True. Any ideas would be greatly appreciated. Frederick Chow Hong Kong. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Please disregard! I didn't mean to send that, as it is not correct.
Dana DeLouis <snip |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
File in Exclusive Use | Excel Discussion (Misc queries) | |||
2 IF Statements not mutually exclusive | Excel Discussion (Misc queries) | |||
Exclusive choice checkbox | Excel Programming | |||
On exclusive open for write | Excel Programming | |||
Exclusive use Problem | Excel Discussion (Misc queries) |