Convert Studio X from Excel in double

Hello,

could you please help me - I have the following expression in a Type Into activity

CurrentRow.ByField(String.Format(“Field”).ToString(New System.Globalization.CultureInfo(“de-DE”))

Now I have only the problem to convert it into double with 2 decimals. If I write cdbl it always leads to an error message

Thank you for your help!

HI @christian1

could you elaborate your task a bit more?

Regards
Gokul

Hello, thank you !

I have the following situation:
I have an Excel File which should be the base for a SAP posting. So I have this field amount in Excel which is for example 100,550303.
In Germany we have our decimals with , and not with . (point). So I received the help from a colleague that I have to set up the CultureInfo to (de-DE) and so the . changed to a comma which is perfect.

But now I have the problem that I have to extend my settings that I can format to a double figure, but I am not really good in programming .

Thx!

HI @christian1

Have you tried with the replace method ?
like your values will be like this 100.550303 right ?
So you can try with “100.550303”.Replace(".",",")

Regards
Gokul

1 Like

grafik
CDbl(100.550303)
100.550303
CDbl(100.550303).toString(“F2”)
“100.55”
CDbl(100.550303).toString(“F2”, New System.Globalization.CultureInfo(“de-DE”))
“100,55”

CDBl (or other conversion) will convert input to double
using a string as input it has to follow some specific formattings other wise we have to handle additional
Does mean in → double

when we want get back a different format we can specify it
Does mean double → string in needed format
And as you can see above with using the DE Globalization we got the comma as decimal seperator

so in your case jsut check on how the string is stored withinn the datatable and if it can be handled with CDbl

CDbl(CurrentRow("Field").toString.Trim).toString("F2", New System.Globalization.CultureInfo("de-DE")

we prefer to use these approaches instead of string manipulations as in unforseen scenarios the dot, comma replacements can harm without getting detected / throwing exceptions
Bug risk scenario:
grafik
the wrong intended change edits the value from 123456 and decimal part 23 to 123 mio 456 Ths And 23

And also:


we would recommend to use a variable for New System.Globalization.CultureInfo(“de-DE”) for shortening the codes

I really thank you ! that sounds very helpful, but I have tried it and Studio X is sending an Error ?

image

can you see my fault?

thank you i will try it and give you feedback

please share a screenshot of the implementation part and of the validation mark message. thanks

image

CDbl((CurrentRow.ByField(“Betrag”).ToString(“f2”, New System.Globalization.CultureInfo(“de-DE”))

is this fine?

du hast einen Klammerfehler und vermischt parsen und Ausgabeformatierung
Auch beachte bei Formatierungs konstanten (F2) die Groß-Kleinschreibung

when the value from the row can be directly used in CDBL give a try on

CDbl(CurrentRow.ByField(“Betrag”)).toString(“F2”, New System.Globalization.CultureInfo(“de-DE”))

in case of it is failing again, let us know the validation message and ive us more context with a screenshot of surrounding activities

1 Like

Vielen herzlichen Dank ! das funktioniert perfekt !
Viele Grüße ! :grinning:

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