Classic ASP FormatNumber weirdness

We have a recently internationalized application written in classic ASP. The following code replicates the problem. The value of this field in the recordset is "8.90" and is entered as varchar (255).

session.LCID = 2057
nNumber = recMessages.fields(lCounter)
Response.Write nNumber '' # prints 8.90
Response.Write FormatNumber(8.90) '' # prints 8.90
Response.Write FormatNumber(nNumber) '' # prints 8.90

session.LCID = 1034
nNumber = recMessages.fields(lCounter)
Response.Write nNumber '' # prints 8.90
Response.Write FormatNumber(8.90) '' # prints 8,90
Response.Write FormatNumber(nNumber) '' # prints 890,00!

      

What's going on here? Why would it multiply the number by 1000 for certain locales?

+2


source to share


3 answers


From what you provided, it looks like it does. in 8.90 is treated as a thousandth separator Is LCID 1034 Spanish?

I'm not sure, but I think if you check the number formatting for that locale it will use the period as the separator.



Greetings

+4


source


Different locales use different characters as decimal and thousands of separators. Although the period (.) Is the decimal separator in the 2057 locale, it is most likely used as the thousands separator in the 1034 locale.

To work around this problem, you can try replacing the dot character in the field value with a specific decimal point separator. I'm not sure, but something like this should work:



session.LCID = 1034
strDecSep = Mid(CStr(CDbl(3/2)), 2, 1)
nNumber = recMessages.fields(lCounter)
nNumber = Replace(nNumber, ".", strDecSep)

      

0


source


This does not mean that it is multiplied by 1000. This number is formatted in the country currency format. For example, in the United States, 1234.56 would be formatted as $ 1,234.56, in Spain the same number would be 1.234.56

0


source







All Articles