Uipath中GenericValue报错

在输入文本框中使用GenericValue类型时,报错。由于要使用小数或者整数,选取了GenericValue这一类型。整体流程没有问题,但是在运行的时候,输入任何数字都会报错弹出输入对话框: TypeConverter cannot convert from System.String.我无法解决,希望有人能帮我

Hi @469467255 ,

Could you try converting the variable to string?

gen_variable.ToString

If I’ve interpreted your query correctly, then passing in a String Variable itself should do the trick, even if you are inputting integer values:

image

image

Just convert that value to Integer if you want to use it as a number within the flow using this

Convert.ToDouble(str_variable)
Convert.ToDecimal(str_variable)

Kind Regards,
Ashwin A.K

In fact, the variable I set is string by default, but I need to change it to Genericvalue. There will be an error when inputting decimal during operation

I’m just a beginner. I want to use a small process to judge whether the asset liability ratio is stable. I set it to be stable between 0.4 and 0.6. The overall process is as follows: in the first dialog box, the user needs to input the asset liability ratio, and then judge it to draw a stable or unstable conclusion. My variable is zcfzl and the default is string. After changing it to genericvalue, run the program and report an error. The code is: input dialog box: TypeConverter cannot convert from system String.

Hi @469467255 ,

I’ve created a short sequence for you, could you please verify whether it performs the operation as expected?

If(Convert.ToDouble(str_variable)<0.4 OrElse Convert.ToDouble(str_variable)>0.6,"Liability is unstable","Liability is stable")

LiabilityCheck.xaml (6.5 KB)

Kind Regards,
Ashwin A.K

Thank you first. In fact, I already know that I can use double to complete the process before asking, but I can’t understand why my other classmates and teachers can directly solve this problem through genericvalue, but I can’t.

Hi @469467255 ,

EDIT:

I was able to achieve the result after editing out the Convert class:

image

LiabilityCheck_v1.xaml (6.0 KB)

Kind Regards,
Ashwin A.K