ToString("C") fails

I’m retrieving a Double from a spreadsheet or data table. I want to write the value to a Word doc using Replace Text. My Replace with is: TotalPortfolio.ToString(“C”) which produces an unprintable character instead of a dollar sign ($). The same with WriteLine: TotalPortfolio = ¤7,733.33.

I tried “C2” and that didn’t work.
I tried (“C2, en-US”) and that gave me an error.

As a workaround I’m using this: “$” +TotalPortfolio.ToString(“N2”)

Thoughts on why C for currency isn’t working?

Hi @cgoldstein

could you try with

TotalPortfolio.ToString("C2", CultureInfo.CurrentCulture)

Regards

Hi @cgoldstein
Try this:

TotalPortfolio.ToString("C2", New System.Globalization.CultureInfo("en-US"))

Hope it helps!!

Hi,

¤ (U+00A4) is unknown currency sign due to invariant culture

As another approach, call the following expression in advance

System.Globalization.CultureInfo.CurrentCulture = New System.Globalization.CultureInfo("en-US")

then

TotalPortfolio .ToString("C")

Please note that this may affect other methods or properties which is related with cultureinfo.

Regards,

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