0

In .net VB have a multi-lingual and multi-currency price listing that comes from two sources. For prices coming from our SQL server where prices are held as a Money datatype, all is well if we change languages. i.e. US$599.00 in English is displayed as US$599,00 in Italian.

Currency and price are separate fields, btw.

However, when the data source is from our partners web service when the data is a string, then US$599.00 is still correct in English but when in Italian, Spanish or German it is US$599.00,00. I can't work out what's going wrong with it. Not all prices are full units so I can't just parse an integer.

Any advice would be appreciated.

Craig
  • 1,704
  • 1
  • 18
  • 36
  • So to recap: you're having trouble parsing the string `"US$599.00"` to a decimal? – CodeCaster Jul 05 '13 at 10:00
  • Nope. The string from the web service is "599.00". If I Convert.ToDecimal(theString) I still get 599.00,00 when displayed in the datagrid output. – Craig Jul 05 '13 at 12:15

1 Answers1

1

The string from the web service is "599.00". If I Convert.ToDecimal(theString) I still get 599.00,00 when displayed in the datagrid output.

If the string from the web service always uses a dot as decimal separator, convert using the InvariantCulture, which has a . as DecimalSeparator:

decimal amount = Convert.ToDecimal("559.00", CultureInfo.InvariantCulture);
CodeCaster
  • 147,647
  • 23
  • 218
  • 272