Javatpoint Logo
Javatpoint Logo

VBA Compression Operator

Compression operators compare two expressions and return Boolean values that represent the relationship of their values.

Compression operator is used to comparing values for validation proposes. In VBA, compression operators include less than (<), greater than (>), equal to (=), less than equal to (<=), greater than equal to (>=), and not equal to (?).

Let's see all the compression operator through the examples as follows:

1. Equal (=): The equal to operator is used to check if the two values are equal and return True or False. It is also used as an assignment operator.

For example,

In the above example, we check int x is equal to int y. If it is True, the value of the Boolean blnResult will be True. Otherwise, it will be False.

Output:

blnResult = True

2. Not equal to (≠): Not equal to operator is used to check if two values are not equal and return True or False.

For example,

3. Greater than (>): Greater than operator is used to check if the first value is greater than the second value and returns True or False.

For example,

In the above example, we check int x is greater than int y. If it is True, the value of the Boolean blnResult will be True. Otherwise, it will be False.

Output:

blnResult = True

4. Greater than equal to (>=): The greater than equal to operator is used to check if the first value is greater than or equal to the second value and returns True or False.

For example,

In the above example, we check if int x is greater than or equal to int y. If it is True, the value of the Boolean blnResult will be True. Otherwise, it will be False.

Output:

as both variables are equal to 5 the blnResult returns True.

5. Less than (<): Less than operator is used to check if the first value is less than the second value and returns True or False.

For example,

In the above example, we check int x is less than int y. If it is True, the value of the Boolean blnResult will be True. Otherwise, it will be False.

Output:

blnResult = True

6. Less than equal to (<=): Less than equal to operator is used to check if the first value is less than or equal to the second value and returns True or False.

For example,

In the above example, we check if int x is less than or equal to int y. If it is True, the value of the Boolean blnResult will be True. Otherwise, it will be False.

Output:

As both variables are equal to 10, and the blnResult returns True.





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA