How to use the logical operator "!"?

Hi,

I want to do a while loop with a string.

The loop turns while the string IS NOT equal to a string I specify.

I try to use the ! operator but it doesn’t works.

Witch are the negation operator in UiPath?

Thanks

Hi @nSangui,

Since UIPath is based on VB .NET to develop artifacts, in this case the correct operator is Not.

For example:

6 Likes

Hi,

“!” is a C operator, you need VB.Net (which btw is “Not”).
You can check VB.Net operators here:
VB.Net - Operators

Regards,
Andrzej

4 Likes

You can use <> for not equal.
example: value <> 1

7 Likes

Sidenote; I tend to avoid using Not when there is more than one condition as it gets confusing. For example if you had

If
Not isMale or age > 21

Would that be interpreted as not Male and not over 21 or not Male and could be any age? Without testing I’m not sure hence why I would avoid using Not.

So what do you use instead of not?

Try to make the operation a positive one, so rather than saying

not age > 21

say

age <= 21

to avoid the confusion. Not always possible, if it gets too confusing just use one nested if (but no more than one!! :slight_smile: )

2 Likes