I am maintaining an app for a client that is used in two locations. One in England and one in Poland.
The database is stored in England and uses the format £1000.00 for currency, but the information is being gathered locally in Poland where 1000,00 is the format.
My question is, in VB6 is there a function that takes a currency string in a local format and converts to another, or will I just have to parse the string and replace , or . ?
BTW I have looked at CCur, but not sure if that will do what I want.
The data is not actually stored as the string
"£1000.00"; it’s stored in some numeric format.The database appears to be storing the number as
"£1000.00"because something is formatting it for display. In VB6, there’s a functionFormatCurrencywhich would take a number like 1000 and return a string like"£1000.00".You’ll notice that the
FormatCurrencyfunction does not take an argument specifying what type of currency to use. That’s because it, along with all the other locale-specific functions in VB, figures out the currency from the current locale of the system (from the Windows Control Panel).That means that on my system,
will print
$1,000.00, but if I run that same program on a Windows computer set to the UK locale, it will probably print£1,000.00, which, of course, is something completely different.Similarly, you’ve got some code, somewhere, I can’t tell where, in Poland, it seems, that is responsible for parsing the user’s string and converting it to a number. And if that code is in Visual Basic, again, it’s relying on the control panel to decide whether "." or "," is the thousands separator and whether "," or "." is the decimal point.
The function
CDblconverts its argument to a number. So for example on my system in the USproduces the number one point two, on a system with the Control Panel set to European formatting, it would produce the number one thousand, two hundred.
It’s possible that the problem is that you have someone sitting a computer with the regional control panel set to use "." as the decimal separator, but they’re typing "," as the decimal separator.