Error in convert string to double

Hi All,

I am facing error while converting my string to double.
can anyone pls check and suggest:

amt_tobePaid is string
doubleAmttobePaid is string
userInput is system.Double

Capture

Capture

Does double.Parse(doubleAmttobePaid) not work?

Whats the error you are getting ?

Try CDBL(string) @somya177, it will work

@somya177 Can you try to pass fully Qualified name instead of β€œdouble.Parse” to system.double.Parse and let us know.

Hi @somya177

Double.Parse will only convert to double if you do not have any special characters in the string. In case you have special characters, please make sure to remove them before the conversion. CDBL(String) will do this automatically for basic stuff like the thousand separator (comma, not other types).

If there are any special characters, you can do a string.Replace to replace them.

1 Like

Exactly, this will work @somya177 :slight_smile:

1 Like

@somya177,
Try,
Convert.ToDouble(amt_tobePaid).ToString,
and Convert.ToDouble(doubleAmttobePaid).ToString
Then assign this to userInput which of datatype double.

Hey Guys (@HareeshMR, @Lahiru.Fernando, @sagaryeole (can’t tag more)),

I am facing the same/similar issue and can’t seem to figure it out. I have tried all the possible scenario’s I can think off and all give me an error regarding the format (Input string was not in a correct format.). Please see the some of the scernario’s I have tested.

So my input comes from a get text activity which is a percentage like #,## / 0,05 / -0,05.
I need to write it to a DT aftwards since I need this information later on in a IF statement (>=, <= etcetera).

five_min = String
dbl_five_min = System.Double

Scenario 1
Assign
five_min TO five_min.Replace(β€œ-”, β€œβ€).Replace(β€œ,”,β€œ.”).Trim
also tried with five_min TO five_min.Replace(β€œ-”, β€œβ€).Trim

then

Assign
dbl_five_min TO CDbl(five_min)

Scenario 2
five_min TO five_min.Replace(β€œ-”, β€œβ€).Replace(β€œ,”,β€œ.”).Trim
also tried with five_min TO five_min.Replace(β€œ-”, β€œβ€).Trim

then

Assign
dbl_five_min TO CDbl(five_min)

Scenario 3
Assign
dbl_five_min TO Convert.ToDouble(five_min.ToString.Replace(β€œ,”,”.”).Replace(β€œ-β€œ,””))
also tried TO Convert.ToDouble(five_min.ToString.Replace(β€œ-β€œ,””))

Scenario 4
Assign
five_min TO five_min.Replace(β€œ-”, β€œβ€).Replace(β€œ,”,β€œ.”).Trim
also tried with five_min TO five_min.Replace(β€œ-”, β€œβ€).Trim

then

Assign
dbl_five_min TO Double.Parse(five_min)

Scenario 5
Assign
five_min TO five_min.Replace(β€œ-”, β€œβ€).Replace(β€œ,”,β€œ.”).Trim
also tried with five_min TO five_min.Replace(β€œ-”, β€œβ€).Trim

then

Assign
dbl_five_min TO System.Double.Parse(five_min)

Scenario 6
Assign
five_min TO five_min.Replace(β€œ-”, β€œβ€).Replace(β€œ,”,β€œ.”).Trim
also tried with five_min TO five_min.Replace(β€œ-”, β€œβ€).Trim

then

Assign
dbl_five_min TO Convert.ToDouble(five_min, Culture)

Culture =
	Variable type = system.Globalization.CulturInfo
	Default = new CultureInfo("nl")

As you probably can imagine… I am pretty lost by now. I hope you guys can help me out.