Operators

Created by akaBot Support, Modified on Tue, 6 Aug, 2024 at 2:58 PM by akaBot Support

Table of Contents

  1. Arithmetic Operators
  2. String Concatenation Operators
  3. Comparison Operators
  4. Logical Operators


These operators can be set as VB expressions in the properties of activities or used as conditions for judgments. They can also be combined. When combined, they are interpreted from left to right, but you need to consider the precedence of the operators. You can use parentheses ( ) to specify the precedence. When combining operators, it is better to use parentheses ( ) as needed to ensure the intended operations are performed correctly.

1. Arithmetic Operators

These operators are used for performing calculations, including the four basic arithmetic operations. The rules of calculation are the same as in arithmetic, where multiplication and division take precedence over addition and subtraction. To specify the order of calculations, use parentheses ( ) as in arithmetic.

Operator
Example and Result
+
Addition
-
Subtraction
*
Multiplication
/
Division
¥
Integer Division
Mod
Remainder
^
Exponentiation

2. String Concatenation Operators

The "+" operator not only adds numbers but also concatenates strings. When you use the "+" operator with String types (strings), the result is a concatenated string. Even when numbers are stored as strings (String type), they will not be added but concatenated as strings. You can also use the "&" operator for string concatenation.


Operator
Description
Example and Result
+
String Concatenation Operator
"akaBot" + "Studio" = "akaBotStudio"


"2020" + "10" = "202010"
&
String Concatenation Operator
"akaBot" & "Studio" = "akaBotStudio"


"2020" & "10" = "202010"

3. Comparison Operators

Also called relational operators. If the relationship represented by the operator holds, it returns true (True); otherwise, it returns false (False). Comparison operators do not have precedence among themselves. When used with logical operators, comparison operators take precedence.

Operator
Example and Result
=
Equals
<>
Not Equals
<
Less Than
>
Greater Than
<=
Less Than or Equal To
>=
Greater Than or Equal To

4. Logical Operators

These operators perform operations on logical values (True/False). They are used when combining multiple conditions. When used with comparison operators, the comparison operators take precedence. Among logical operators, the precedence order is "Not → And → Or → Xor". Use parentheses ( ) to specify the precedence if needed. Let's look at each operator one by one.

Not The "logical negation" operator. Written as "Not condition A". It means "not condition A". If condition A is True, the result is False; if condition A is False, the result is True. For example, to determine if a value is "odd", you can check if "the remainder when divided by 2 is not 0". The expression would be "Not value Mod 2 = 0", which returns True if the value is odd.

Condition A
Result
Not A
Not var Mod 2 = 0 example
True
False
False
True

Example:

  • If var is 10, "10 Mod 2 = 0" is True. Since "Not True" is evaluated, the result is False.
  • If var is 5, "5 Mod 2 = 0" is False. Since "Not False" is evaluated, the result is True.

And The "logical conjunction" operator. Written as "condition A And condition B". The result is True only if both condition A and condition B are True. For example, to determine if a value is "even and less than 100", check if "the remainder when divided by 2 is 0 and less than 100". The expression would be "(value Mod 2 = 0) And (value < 100)", which returns True if the value is "even and less than 100".

Condition A
Condition B
Result
A And B
(var Mod 2 = 0) And (var < 100) example

True
True
True
True
False
False
False
True
False
False
False
False

Example:

  • If var is 60, "60 Mod 2 = 0" and "60 < 100" are both True. Since "True And True" is evaluated, the result is True.
  • If var is 100, "100 Mod 2 = 0" is True and "100 < 100" is False. Since "True And False" is evaluated, the result is False.
  • If var is 3, "3 Mod 2 = 0" is False and "3 < 100" is True. Since "False And True" is evaluated, the result is False.
  • If var is 101, "101 Mod 2 = 0" and "101 < 100" are both False. Since "False And False" is evaluated, the result is False.

Or The "logical disjunction" operator. Written as "condition A Or condition B". The result is True if either condition A or condition B is True. For example, to determine if a value is "even or greater than 1000", check if "the remainder when divided by 2 is 0 or greater than 1000". The expression would be "(value Mod 2 = 0) Or (value > 1000)", which returns True if the value is "even or greater than 1000".

Condition A
Condition B
Result
A Or B
(var Mod 2 = 0) Or (var > 1000) example

True
True
True
True
False
True
False
True
True
False
False
False

Example:

  • If var is 1020, "1020 Mod 2 = 0" and "1020 > 1000" are both True. Since "True Or True" is evaluated, the result is True.
  • If var is 100, "100 Mod 2 = 0" is True and "100 > 1000" is False. Since "True Or False" is evaluated, the result is True.
  • If var is 1001, "1001 Mod 2 = 0" is False and "1001 > 1000" is True. Since "False Or True" is evaluated, the result is True.
  • If var is 1, "1 Mod 2 = 0" and "1 > 1000" are both False. Since "False Or False" is evaluated, the result is False.

Xor The "exclusive or" operator. Written as "condition A Xor condition B". The result is True if either condition A or condition B is True, but not both. It is not commonly used.

Condition A
Condition B
Result
A Xor B
(var Mod 2 = 0) Xor (var > 1000) example

True
True
False
True
False
True
False
True
True
False
False
False

Example:

  • If var is 1020, "1020 Mod 2 = 0" and "1020 > 1000" are both True. Since "True Xor True" is evaluated, the result is False.
  • If var is 100, "100 Mod 2 = 0" is True and "100 > 1000" is False. Since "True Xor False" is evaluated, the result is True.
  • If var is 1001, "1001 Mod 2 = 0" is False and "1001 > 1000" is True. Since "False Xor True" is evaluated, the result is True.
  • If var is 1, "1 Mod 2 = 0" and "1



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article