How to Use Not Condition in UiPath?

Not operator performs logical negation on Boolean expression. We will see how to use this Not operator in UiPath. It is a Visual Basic (VB) operator.

Syntax:

result = Not expression

where, result is a variable of type Boolean and expression is a Boolean expression.

For example, if the expression is True, then result will be False. Also, if the expression is False, then the result will be True.

Usage in UiPath

Initialize two variables of type Integer and assign them a value using Assign activity. I have used num1 and num2 as Integer variables and assigned them the value 5 and 16 respectively.

Initialize two variables of type Integer and assign them a value using Assign activity for Not operator usage in UiPath

I will show you two ways of using the Not operator in UiPath:

  1. Using Assign activity and print the result value on output console.
  2. Using If Condition activity

Using Assign activity

Add another Assign activity and create a variable result of type Boolean. Assign the value of result with the below expression.

result = Not (num1 > num2)

Use a Write Line activity to print the result on the output console.

Usage of Not operator in UiPath in Assign activity

The expression (5 > 16) evaluates to False. The negate of expression is True. Therefore, the result value on the console is True.

Console Output showing the value of result evaluated as Not of expression in UiPath

Using If Condition activity

Add an If activity and write the below condition. Also, put a Write Line activity to print the respective comments on the output console.

Not (num1 < num2)
Using Not operator in UiPath with If activity

The expression (5 < 16) evaluates to True. The negate of expression is False. Therefore, the control will go to Else part and print Inside Else on the output console.

Output console for using Not operator in UiPath using If activity

Thank you All!!! Hope you find this useful.


Leave a Reply

Up ↑

%d