![]() If the first expression in an OrElse expression evaluates to True, then the second expression is not evaluated because it cannot alter the final result, and OrElse returns True. Similarly, the OrElse Operator performs short-circuiting logical disjunction on two Boolean expressions. If the first expression in an AndAlso expression evaluates to False, then the second expression is not evaluated because it cannot alter the final result, and AndAlso returns False. The key difference between the two is that AndAlso exhibits short-circuiting behavior. The AndAlso Operator is very similar to the And operator, in that it also performs logical conjunction on two Boolean expressions. ' The preceding statements set e to True, f to False, and g to False. ' The preceding statements set c to True and d to False. ' The preceding statements set a to True and b to False. The following example illustrates the And, Or, and Xor operators. If both expressions evaluate to True or both evaluate to False, Xor returns False. If exactly one expression evaluates to True, but not both, Xor returns True. The Xor Operator performs logical exclusion on two Boolean expressions. If neither expression evaluates to True, Or returns False. If either expression evaluates to True, or both evaluate to True, then Or returns True. The Or Operator performs logical disjunction or inclusion on two Boolean expressions. If at least one of the expressions evaluates to False, then And returns False. If both expressions evaluate to True, then And returns True. The And Operator performs logical conjunction on two Boolean expressions. ![]() ' The preceding statements set x to False and y to True. If the expression evaluates to True, then Not returns False if the expression evaluates to False, then Not returns True. It yields the logical opposite of its operand. The Not Operator performs logical negation on a Boolean expression. Some of these operators can also perform bitwise logical operations on integral values. The And, Or, AndAlso, OrElse, and Xor operators are binary because they take two operands, while the Not operator is unary because it takes a single operand. Logical operators compare Boolean expressions and return a Boolean result.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |