I have a string variable with value “1.000,00”. I want to convert this string to a double value in the pt-pt format. I’ve tried the following code:
When I run the code, it always returns an error!
Can you find what is wrong?
Welcome to our UiPath Forum!
What is the error that you are getting?
The error is: “Assign TEMP txtMontanteReduzir_double: Input string was not in a correct format.”
The desired output is 1000,00
Looks like you will need to work on your CultureInfo a bit. See here:
First initialize your CultureInfo variable:
nfi = new CultureInfo("pt-pt")
It should be of type:
Then, assign these:
nfi.NumberFormat.NumberGroupSeparator = "."
nfi.NumberFormat.NumberDecimalSeparator = ","
Finally, do your conversion:
Here it displayed it as
1000.00, but that can be fixed by adding your culture to the ToString of the Write Line:
Decimal.Parse("1.000,00", nfi).ToString(new CultureInfo("pt-pt"))
Thank you very much!
Now it’s working perfectly!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.