The VBScript logical operators are And (logical AND), Or (logical OR), Not (logical negation), Imp (logical implication), Xor (exclusive OR) and Eqv (logical equivalence). Figure 24.3 shows truth tables for these logical operators. Note: Despite the mixture of case in keywords, functions, etc., VBScript is not case-sensitive—uppercase and lowercase let-ters are treated the same, except, as we will see, in character string constants (also called character string literals).
VBScript provides the plus sign, +, and ampersand, &, operators for string concatena-tion as follows:
s1 = "Pro"
s2 = "gram"
s3 = s1 & s2
s3 = s1 + s2
The ampersand is more formally called the string concatenation operator. The above state-ments would concatenate (or append) s2 to the right of s1 to create an entirely new string, s3, containing "Program".
If both operands of the concatenation operator are strings, these two operators can be used interchangeably; however, if the + operator is used in an expression consisting of varying data types, there can be a problem. For example, consider the statement
s1 = "hello" + 22
VBScript first tries to convert the string "hello" to a number, then add 22 to it. The string "hello" cannot be converted to a number, so a type mismatch error occurs at run time. For this reason, the & operator should be used for string concatenation.
Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.