==========
PB
==========
Example 8 The following code sets the color of the text according to the value of the 单 选 风 风 文 文 文 文 文 文 文 文 文 文 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为 为Default_color = 0 // Black MOD_STRING = "YES_OR_NO.COLOR = '" String (default_color) & "~ TIF (Yes_OR_NO = ~~' Y ~~ '," String (Color1) "," & String Default_color) ") '" "Err = dw_emp.modify (mod_string) if Err <>" "TheenMessageBox (" Status ", &" Modify YES_OR_NO Column text color failure error position is " ERR) Returnend IF
=========
VB
=========
This example uses the IIF function to calculate the TestME parameter of the checkit process, and if the parameter value is greater than 1000, the word "lar" is returned "Small".
Function Checkit (Byval Testme As Integer) AS STRING
Checkit = IIF (TestMe> 1000, "Large", "Small")
END FUNCTION
==========
C #
==========
?: The operator is called the conditional operator. Sometimes it is also known as a three-yuan operator.
Conditional-expression: (Conditional expression :)
Conditional-OR-Expression (condition or expression)
Condition-or-expression?
EXPRESSION:
Expression (condition or expression? Expression: expression)
B? x: Ye format The conditional expression first calculates the condition B. Then, if B is True, X and it becomes an operation result. Otherwise, y, and it becomes an operation result. The conditional expression calculates X and Y at different times. The condition operator is associated with the right, indicating the operation from right to left. For example, the expression of a? B: c? D: e-form Press A? B: (C? D: E). ?: The first operand of the operator must be an expression that can be implicitly converted to the type of BOOL, or an expression of the type of Operator True. If the two requirements are not met, the compile time is incorrect. ?: The second and third operands of the operator determine the type of conditional expression. Sets X and Y as the type of the second and third operands. Then, if the types of X and Y are the same, this type is the type of the conditional expression. Otherwise, if there is an implicit conversion from X to Y (Section 6.1), there is no implicit conversion from Y to X, then Y is the type of conditional expression. Otherwise, if there is an implicit conversion from Y to X (Section 6.1), there is no implicit conversion from X to Y, then X is the type of conditional expression. Otherwise, the type of conditional expression cannot be determined, and the compile time is incorrect. B? X: Yeng's conditional expression runtime processing includes the following steps:
First calculate B and determine B BOOL value:
If there is an implicit conversion from the type to BOOL, this implicit conversion is performed to generate the BOOL value. Otherwise, call the Operator True defined in B to generate the BOOL value. If the BOOL value generated by the above step is true, X and convert it into a type of conditional expression, and this is the result of the conditional expression. Otherwise, y and convert it into a type of conditional expression, and this is the result of the conditional expression. ======= SQL Server ======= iif returns one of the two numerical or string values determined by the logic test. Grammatical Digital IIF («logical expression», «Numeric Expression1», «Numeric Expression) If« logical expression »True is True, this function returns« Numeric Expression1 », otherwise, return« Numeric Expression2 ». String IIF («Logical Expression», «String Expression1», «String Expression») If «Logical Expression» This function returns «String Expression1», otherwise, return «String Expression2». Note Only when the value of «logical expression» is zero, this expression is False. Any other value is interpreted as True. It is not recommended to use the IIF function to create a collection of members based on search criteria. Please use the Filter function to evaluate each member in the specified collection according to the logical expression, and then return to the subset of members. Example Number If MeasureS.CurrentMember is an empty unit, the following example returns 0, otherwise returns 1: IIF (ISempty (MeasureS.currentmember), 0, 1) String If MeasureS.CurrentMember is a empty unit, then the following string returns String "YES", otherwise returns "NO": IIF (ISempty (MeasureS.currentmember), "Yes", "NO")