OverflowStacker
OverflowStacker

Reputation: 1338

vba grouping of logical operators

Basically i want then Negated Or (NOR)

in vba i want to achieve the following logical grouping in an if statement:

x1 or x2 or x3 or <SPAN STYLE="text-decoration:overline">x4 or x5</SPAN>

The first 3 conditions are just connected with or. The last 2 conditions shall first be evaluated with or and then negated.

So far i tried:

x1 or x2 or x3 or not (x4 or x5)

but that doesn't seem to work.

EXAMPLE:

IF textbox1 = "" or textbox2 = "" or textbox3 = "" or not (option1 = false
or option2 = false) 

Basically i want then Negated Or (NOR)

0 0 -> 1
0 1 -> 0
1 0 -> 0
1 1 -> 0

Upvotes: 0

Views: 652

Answers (2)

DisplayName
DisplayName

Reputation: 13386

not actually an answer but hopefully a helping code to make you go further:

Sub Logicals()
    Dim x1 As Boolean, x2 As Boolean, x3 As Boolean, x4 As Boolean, x5 As Boolean

    If x1 Or x2 Or x3 Or Not (x4 Or x5) Then MsgBox "Got it" ' prompts the message "Got it", since x1, x2, and x3 are False by default and Not (x4 Or x5) = True (being both x4 and x5 False)


    x4 = True ' the same with x5 = True
    If x1 Or x2 Or x3 Or Not (x4 Or x5) Then MsgBox "Got it" ' doesn't prompt the message "Got it" since x1, x2, and x3 are False by default and Not (x4 Or x5) = False (being x4 True)

End Sub

Upvotes: 1

frog
frog

Reputation: 26

Are x4 and x5 are supposed to be a combined logic? So the outcome of this comparison should be the bool value of the larger logic, with x1, x2 and x3?

Do you perhaps intend to mean:

x1 or x2 or x3 or (x4 and x5)

This way: if either x4 or x5 is false, it will return as a false.

Upvotes: 1

Related Questions