Hello All,
I get text from mainframe as string (I have two values ) like this:
val1=526.12,50-
val2=226.78,20-
I want to do the addition (sum) between the two
what is the good approach to use in order get the result
tHANK YOU
Hello All,
I get text from mainframe as string (I have two values ) like this:
val1=526.12,50-
val2=226.78,20-
I want to do the addition (sum) between the two
what is the good approach to use in order get the result
tHANK YOU
Hello @nora_ziani ,
You can use the below to get the Sum :
(Cdbl(Val1.Replace(“-”,“”).Replace(“,”,“”))+CDbl(Val2.Replace(“-”,“”).Replace(“,”,“”))).ToString
Regards,
Rohith
Hi,
FYI, another solution:
Double.Parse(val1.Trim("-"c),System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))+Double.Parse(val2.Trim("-"c),System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))
Regards,
Hello,
thank you but i think i must have this value
752.90,70
Hi,
Is .
thousand separator? If so, the following will work.
(Double.Parse(val1.Trim("-"c),System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))+Double.Parse(val2.Trim("-"c),System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))).ToString("N2",System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))
Regards,
Hello,
Thank you for the response but just it gives this value 75.290,70
I think it is not correct
@nora_ziani How about using this in assign activity
Cdbl(Str1.Replace("-","").Replace(",","").Trim) + Cdbl(Str2.Replace("-","").Replace(",","").Trim)
Output
Refer attached workflow
Example.zip (2.8 KB)
Hi,
Do you mean your string has 2 value : 526.12 and 50 ?
Or, can you clarify definition of ","
and "."
in the string? For example, the above expression handles .
as thousand separator and ,
as decimal separator like European style.
Regards,
yes , it is like double type it is one number
HI,
Alright, can you try the following?
System.Text.RegularExpressions.Regex.Replace((Double.Parse(val1.Trim("-"c),System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))+Double.Parse(val2.Trim("-"c),System.Globalization.CultureInfo.CreateSpecificCulture("ES-es"))).ToString("F2",System.Globalization.CultureInfo.CreateSpecificCulture("ES-es")),"(?<=\d)(?=\d\d\,)",".")
Regards,