decimal symbol - localization

iolanda

New member
Joined
Jun 3, 2004
Messages
3
Programming Experience
10+
My application reads data from a database, in which the decimal point is "."
If I run the application on a computer when "Regional Options" are set to a locale for which the decimal point is "," all numbers are read incorrectly, by considering "." as a digit grouping symbol.

How can I make my application read numbers correctly even when it is installed on a computer where the decimal point is set to "," ?

Thanks in advance.
 

iolanda

New member
Joined
Jun 3, 2004
Messages
3
Programming Experience
10+
The type of the database column is "Number".

The problem is a little bit more complicated...

I created the (MS Access) database using "." as decimal symbol.
Now, to test the program, I changed the Regional Options to a locale (culture) with "," as decimal symbol. I also changed the keyboard layout accordingly.

Viewed from within Access, all numbers in the db are displayed with ",".

Viewed from within the application (using a bound DataGrid control) the same numbers are displayed with ".", whereas numbers in ordinary text boxes (i.e. those loaded from a data file) are displayed with "," (even if in the data file they have "." as decimal symbol). This could be very confusing for the user.

If I am trying to edit the database from within my application, and I use the "." key on the numerical keypad, an "," is inserted. So, the edited number becomes the only one with an ",". This generates subsequently a calculation error.
 

malbuja

New member
Joined
Jun 16, 2005
Messages
2
Programming Experience
3-5
I had a similar problem. Forget Regional options and keyboard. It´s better than a user works in his locale language.

To edit my Access database I use a small routine to convert comma to point when "," is the decimal symbol. Use this routine when you update the database.

Public Function f_deci(ByVal nume As Single) As String
Dim lst_nume As String, Y As Integer
lst_nume = CStr(nume)
f_deci = lst_nume
Y = InStr(1, lst_nume, ",")
If Y <> 0 Then
f_deci = left(lst_nume, Y - 1) & "." & Mid(lst_nume, Y + 1)
End If
End Function
 
Top Bottom