Vbscript-operators
VBScript-演算子
演算子とは何ですか?
式_4 + 5は9_に等しいとします。 ここでは、4と5は*オペランド*と呼ばれ、+は*演算子*と呼ばれます。 VBScript言語は、次の種類の演算子をサポートしています-
- 算術演算子
- 比較演算子
- 論理(またはリレーショナル)演算子
- 連結演算子
算術演算子
VBScriptは次の算術演算子をサポートしています-
変数Aが5を保持し、変数Bが10を保持すると仮定します-
リンク:/vbscript/vbscript_arithmetic_operators [例を表示]
Operator | Description | Example |
---|---|---|
+ | Adds two operands | A + B will give 15 |
- | Subtracts second operand from the first | A - B will give -5 |
* | Multiply both operands | A* B will give 50 |
/ | Divide numerator by denumerator | B/A will give 2 |
% | Modulus Operator and remainder of after an integer division | B MOD A will give 0 |
^ | Exponentiation Operator | B ^ A will give 100000 |
これらの演算子をよりよく理解するには、http://www.compileonline.com/execute_vbscript_online.php [自分で試してみてください]を使用できます。
比較演算子
VBScript言語でサポートされている次の比較演算子があります-
変数Aが10を保持し、変数Bが20を保持すると仮定します-
リンク:/vbscript/vbscript_comparison_operators [例を表示]
Operator | Description | Example |
---|---|---|
= | Checks if the value of two operands are equal or not, if yes then condition becomes true. | (A == B) is False. |
<> | Checks if the value of two operands are equal or not, if values are not equal then condition becomes true. | (A <> B) is True. |
> | Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. | (A > B) is False. |
< | Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. | (A < B) is True. |
>= | Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. | (A >= B) is False. |
⇐ | Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. | (A ⇐ B) is True. |
これらの演算子をよりよく理解するには、http://www.compileonline.com/execute_vbscript_online.php [自分で試してみてください]を使用できます。
論理演算子
VBScript言語でサポートされている次の論理演算子があります-
変数Aが10を保持し、変数Bが0を保持すると仮定します-
リンク:/vbscript/vbscript_logical_operators [例を表示]
Operator | Description | Example |
---|---|---|
AND | Called Logical AND operator. If both the conditions are True, then Expression becomes True. | a<>0 AND b<>0 is False. |
OR | Called Logical OR Operator. If any of the two conditions is True, then condition becomes True. | a<>0 OR b<>0 is true. |
NOT | Called Logical NOT Operator. It reverses the logical state of its operand. If a condition is True, then the Logical NOT operator will make it False. | NOT(a<>0 OR b<>0) is false. |
XOR | Called Logical Exclusion. It is the combination of NOT and OR Operator. If one, and only one, of the expressions evaluates to True, result is True. | (a<>0 XOR b<>0) is true. |
これらの演算子をよりよく理解するには、http://www.compileonline.com/execute_vbscript_online.php [自分で試してみてください]を使用できます。
連結演算子
VBScript言語でサポートされている次の連結演算子があります-
変数Aが5を保持し、変数Bが10を保持すると仮定します-
リンク:/vbscript/vbscript_concatenation_operators [例を表示]
Operator | Description | Example |
---|---|---|
+ | Adds two Values as Variable Values are Numeric | A + B will give 15 |
& | Concatenates two Values | A & B will give 510 |
変数A = "Microsoft"と変数B = "VBScript"を仮定し、その後-
Operator | Description | Example |
---|---|---|
+ | Concatenates two Values | A + B will give MicrosoftVBScript |
& | Concatenates two Values | A & B will give MicrosoftVBScript |
注意-数字と文字列には連結演算子を使用できます。 変数が数値または文字列値を保持する場合、出力はコンテキストに依存します。
これらの演算子をより良い方法で理解するには、http://www.compileonline.com/execute_vbscript_online.php [自分で試してみてください]を使用できます。