Currency format Change

Hi ,
I have a string that can be of any type such as -122.5,-1785 or 38.34,-12 or 36 or -12.
I need to convert it to a $1,785.00 format without using the format value activity.
As of now I tried to use string.Format(“${0:#.00}”, Convert.ToDecimal(YourVariable.ToString)) but the (,) is not added and it is not able to handle values like ( -122.5,-1785) or (-111,-222.67,-444.1).

Kindly, let me know on how to handle this…

Best,
Sudharsan S

@Sudharsan_S
for adding thousand seprator you after converting you can provide .tostring(“0:n2”)
Hope it works

Hi @Sudharsan_S ,

Try the below expression:

String.Format("${0:n}",Cdbl(YourStringValue))

Regards,

grafik

 myCultureInfo = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")
 [en-US]
 myCultureInfo.NumberFormat.CurrencyNegativePattern = 1
 1
 CDbl("-1234.5").toString("C2", myCultureInfo)
 "-$1,234.50"
 CDbl("1234.5").toString("C2", myCultureInfo)
 "$1,234.50"

hi vishal, it is working for only if the value is singular :- -35, 73 ,-124.5 but sometime I get consolidated value like :- 123,-44,-23 in these cases its not working

Thank you,

Hi peter, all the above values are converting to positives…

Thank you,

Hi Shubham, it is working for only if the value is singular :- -35, 73 ,-124.5 but sometime I get consolidated value like :- 123,-44,-23 in these cases its not working

Thank you,

i didnt understand what you are saying. Try only tostring(“N2”) please give one or two example what is wrong going?

have a look here:
grafik

Also have a look on at above edited snippet