Convert from String to Double

I extracted from an invoice the total amount to be paid as string, using Get Text: “5.961,47”.
“.” (point) is the thousands separator and “,” (comma) is the decimal separator.

How can I convert it in double? I tried Double.Parse but I receive error message: Input string was not in a correct format.

Note: I don’t really care if the thousands separator is maintained after convertion.

1 Like

@Cardon_Cezar, Have you tried Convert.ToDouble(“5.961,47”, CultureInfo.InvariantCulture).ToString?

2 Likes

Hi,
First you can try by replacing the text from “.” to “” and “,” to “.” , then you can try using Convert.toDouble(inputText)

2 Likes

Hi @Cardon_Cezar

Try to put in a variable string then use this. Convert.ToDouble(Variable) then let see it.

cheers :smiley:

Happy learning :smiley:

2 Likes

Hi @Bhavik_Solanki

I get the below error:

Hi @Priyanka_Ramesh

I get the below error:
Input string was not in a correct format

@Cardon_Cezar I guess you’re performing the operation in a reverse way :sweat_smile: , Try this :

Convert.ToDouble(“5.961,47”.Replace(“.”,“”).Replace(“,”,“.”))

2 Likes

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