Operators in VBScript. Logical OperatorsVBScript provides a variety of operators that you can use when performing logical operations. For example, if you want to use an If statement that is TRUE if two statements are TRUE, you can use the And operator to combine the statements (If (A = B) And (C > D) Then ). The logical operators available in VBScript are discussed below. Negation Not OperatorThis operator has the following syntax: result = Not expression The result variable in relation to expression is given in table 1.
If you enter the code b=False a = Not b the result stored in variable True. Typically, Not operator is often used when working with if-then conditional statements. Consider, for instance, the following code segment: if expression1=False then msgbox "Enter the correct value" You could use the Not operator to make code easier to read: if Not expression1 then msgbox "Enter the correct value" Conjunction And OperatorThe conjunction operator compares two or more variables in some type of test. The syntax for the conjunction operator is result = expression1 And expression2 The table 2 displays the result variable in relation to expression1 and expression2. In order to obtain True in the result variable, both expression1 and expression2 must be true.
For instance, if you want to make your page available only for user of the age above 16 and male sex, you might use the statement like this if YourAge>16 And YourSex=Male then msgbox "You are welcome" else msgbox "The page is forbidden for you" Disjunction Or OperatorThe syntax and usage of Or operator is similar to And operator: result = expression1 Or expression2 The result variable in relation to expression1 and expression2
The copyright of the article Operators in VBScript. Logical Operators in VB Script is owned by Maxim Karetnikov. Permission to republish Operators in VBScript. Logical Operators in print or online must be granted by the author in writing.
Go To Page: 1 2 Articles in this Topic Discussions in this Topic |