Friday, September 6, 2019

VBA Comparison Operators: Not equal to, Less than or equal to, Greater than

VBA Comparison operators

These are operators that are used to compare values. Comparison operators include equal to, less than, greater than and not equal to
The following table shows VBA Comparison Operators.
Comparison operators are used to compare values for validation purposes. Let's say you are developing a simple point of sale application. In this application, you want to validate the values entered before you post. In such cases, you can use comparison operators. This operator will check against the negative numbers or to ensure that the amount paid does not exceed the billed amount. Comparison operators come in handy in such situations.
S/NOperatorDescriptionExampleOutput
1=Equal: checks if two values are equal. It is also used as an assignment operatorIf x = z ThenReturns true if they are equal, else it returns false
2<Less than: This operator is used to subtract numbersIf x < z ThenReturns true if x is less than z, else it returns false
3>Greater than: This operator is used to multiply numbersIf x > z ThenReturns true if x is greater than z, else it returns false
4<>Not equal to: This operator is used to divide numbersIf x <> z ThenReturns true if they are not equal, else it returns false
5<=Less than or equal to:If x <= z ThenReturns true if x is less than or equal to z, else it returns false
6>=Greater than or equal to:If x >= ThenReturns true if x is greater than z, else it returns false