+ Reply to Thread
Results 1 to 6 of 6

Multiple Logical Operators

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    11

    Multiple Logical Operators

    I am working on a truth table generator that will use multiple Logical operators ( a combination of as many as 15 logical operators ( e.g. And, Or, Not... to solve for a single result.)
    The problem I have run into is the result is fine until you start using the NOT operator in the equation.

    The next line is the equation out of the code according to the equation any "0" input in the third column should return a result of "1" in the fourth column

    = (INPUTval(0) And (Not (INPUTval(1)) Or (Not (INPUTval(2)))))

    0 0 0 0
    1 0 0 1
    0 1 0 0
    1 1 0 1
    0 0 1 0
    1 0 1 1
    0 1 1 0
    1 1 1 0




    When "Not" is used I either get a negative number as a result, or a a wrong result when the equation seems to be written correctly. The code is below. It is a combination of examples off the web and my own doings. any help will be greatly appreciated...

    Thanks in advance, Blues

    This will be pasted in the Work sheet in the top rows (In Bold)

    IN_0 IN_1 IN_2
    Min 0 0 0
    Max 1 1



    Please Login or Register  to view this content.
    Last edited by shg; 06-20-2011 at 01:58 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple Logical Operators

    The closing code tag is [/code], corrected below.

    You're using 1s and 0s as your logical values, but to VBA, logical operations are bitwise operations, so Not 1 (and Not is an operator, not a function, in VBA) is -2 (the inversion of all bits).

    True and False in VBA are the signed 16-bit integers -1 and 0
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-07-2011
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Multiple Logical Operators

    First thanks for the reply ,
    I think I understand what you are saying...
    Then how should the following equation be written

    Please Login or Register  to view this content.
    where it will produce the correct result

    Thanks,Blues
    Last edited by bluesstruggler; 06-20-2011 at 02:31 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multiple Logical Operators

    If you change your 1s and 0s to True and False and change the array types to Boolean, it may work. You can get rid of most of the parens:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-07-2011
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Multiple Logical Operators

    I will give it a try thanks!

    I will update...


    Blues

  6. #6
    Registered User
    Join Date
    06-07-2011
    Location
    california
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Multiple Logical Operators

    solved Thanks for the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1