Convert string "1.205,25-" to a type to calculate with

Hello,

I’ve been extracting data from an SAP transaction (activity ‘extract table data’) and saved it in a datatable variable. The values look like this “1.205,25-”. How can I change this value into a double in able to calculate with it for each row in my datatable?

I’ve tried several options.
This is the last one: Cdbl(CurrentRoyaltyRow(“Bedrag EV”))*(-1)
Error Message: Assign: Conversion from string “1.205,25-” to type ‘Double’ is not valid.

String with endminus to double

Can someone help me out ? Please not only code but integrated in the right activity …

Thanks !
Grz,
Riana

Hi @Riana

Try this

CurrentRoyaltyRow("Bedrag EV") = Convert.ToDouble(CurrentRoyaltyRow("Bedrag EV").ToString().Replace("-", "").Replace(",", ""))

Regards,

Hi @Riana

The suggestion of @lrtetala should work with a slight modification as I am guessing this is in EU formatted SAP data where “.” is a thousand separator and “,” is actually the decimal.

CurrentRoyaltyRow("Bedrag EV") = Convert.ToDouble(CurrentRoyaltyRow("Bedrag EV").ToString().Replace("-", "").Replace(".", "").Replace(",","."))

grafik
we would recommend to import System.Globalization to the namespaces, so you can shorten the statement

1 Like