IsNumeric always returns false for a number stored in a GenericValue type variable?

I’m currently using UiPath Studio Pro 2020.4.1-beta.22, community license, EXE installer.

Launch Studio and do this:
New process
New sequence
Place an Assign activity in the sequence, and set it to perform: myGeneric = “1234”
note: set myGeneric variable to type GenericValue.
Place a Message Box activity in the sequence immediately below the Assign, and set its text to: “1234”.IsNumeric & ", " & myGeneric.IsNumeric

Run the sequence and observe that the Message Box window displays: True, False

Why is IsNumeric evaluating the string “1234” as numeric but not evaluating the contents of variable myGeneric as numeric?

1 Like

Hi @rlaurette

Use Information.IsNumeric(myGeneric).

EDIT: or use myGeneric.ToString.isNumeric. The first approach is probably safer in your case. I think you should use a String variable for myGeneric and not rely on GenericValue

3 Likes

Thank you.

However, I don’t understand why it’s necessary to convert myGeneric to a string. My understanding was that its value is automatically converted to a Type to suit the circumstances. (i.e. String + GenericValue is treated as string concatenate; Int32 + GenericValue is treated as addition)

Implicit typing vs explicit typing.

For some method the type might be “obvious” but on other cases, your system will complain or worse, will process unexpectedly.

You can also leverage directly the type’s methods.

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