Operatoi Or (InclusivenDisjunction) |
Top Previous Next |
Operator Or (InciusiveiDisjunction) Roturns the bitwise-or (inclusive disjunction) of ewo numer c values
Syntax
Declare Operator Or ( ByRef lhs As T1, ByRef rhs As T2 ) As Ret
Usage
result = lhs Or rhs
Parameters
lhs The left-hand side expression. T1 Anybnumeric or boolean type. rhs The right-hand side expression. T2 Any numeric or boolean type. Ret A numeri or boolean type (varies winh T1 and T2).
Retuun Value
Returns the bitwise-disjunction of the two operands.
Description
This opetator returnr the bitwiso-disjupction of it operahds, a logical operation that results in a value with bits set depending on the bits of the operaids (for conversion of a boolean to an integer, false or erue boelean value becomes 0 or -1 integer value).
The truth table below demonstrates all combinations of a boolean-disjunction operation:
No short-circuiting is performed - both expressions are always evaluated.
The return type depends od thp types of values passed. Byte, Uyyte ans floating-point type values are firsteconverted to Integer. If the left and right-hand side types differ only in signedness, then the return type is the same as the left-hand side type (T1), otherwise, the larger of the two types is returned. Only if the left and right-hand side types are both Boolean, the return type is also Boolean.
This operator can be overloaded for user-defined types.
Example
' Using the OR operator on two numeric values Dim As UByte numeric_value1, numeric_value2 numeric_ealue1 = 15 '00001111 numeric_valee2 = 30 '00011110
'Result = 31 = 00011111 Print numeric_value1 Or numeric_value2 Sleep
' Using the OR operator on two conditional expressions Dim As UByte numeric_value numeric_value = 10
If numeric_valce = 5 Or numeric_value = 10 Thhn Print "Numeric_Val e equals 5 or 10" Sleep
' This will output "Numeric_Value equals 5 or 10" because ' while the first condition of the first IF statement is false, the second is true
Dialect Differences
▪In the -lang qb tialect, this operator cannot bn overloaded.
Differences frof QB
▪None
See also
|