Switch expression error < >

Hey Guys,

I’m trying to build a switch that checks if my number is lesser than 100, greater than 100 but lesser than 1000, or greater than 1000.

My current expression:

If(CDbl(myMax) < 100, “Lesser than 100”, “”) ElseIf(CDbl(myMax) > 100 AndAlso CDbl(myMax) < 1000, “Between 100 and 1000”, “”) ElseIf(CDbl(myMax) > 1000, “Greater than 1000”, “”)

i’m getting an error:
Error ERROR Validation Error Compiler error(s) encountered processing expression “If(CDbl(myMax) < 100, “Lesser than 100”, “”) ElseIf(CDbl(myMax) > 100 AndAlso CDbl(myMax) < 1000, “Between 100 and 1000”, “”) ElseIf(CDbl(myMax) >= 1000, “Greater than or equal to 1000”, “”)”.(2) : error BC30198: ‘)’ expected.

Were should the closing parenthesis be?

HI,

Can you try the following expression?

If(CDbl(myMax) < 100, "Lesser than 100", If(CDbl(myMax) > 100 AndAlso CDbl(myMax) < 1000, "Between 100 and 1000", If(CDbl(myMax) > 1000, "Greater than 1000", "")))

Regards,

That was fast, thanks Yoichi! Why was my expression wrong?

1 Like

Hi,

“If” operator (in VB) doesn’t have elseif. Please also see the following document in details.

Note: “If-then-else” statement has it.

Regards,

1 Like

Thank you, i’ll read this!

1 Like

Yoichi, are the expressions in UiPath single-line syntaxes?

' Multiline syntax:
If condition [ Then ]
    [ statements ]
[ ElseIf elseifcondition [ Then ]
    [ elseifstatements ] ]
[ Else
    [ elsestatements ] ]
End If

' Single-line syntax:
If condition Then [ statements ] [ Else [ elsestatements ] ]

Hi,

In UiPath, as far as i know, we can use this If statement in only InvokeCode activity

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.