PDA

View Full Version : Numerical Format Conversion



MWE
06-04-2008, 03:11 PM
Window's langauge setup facilitates I/O of numbers in the format normally used by a particular country as long as the application bothers to check. Applications that work with numbers a lot, like Excel, work pretty well. Applications that do not work with numbers tend to have problems with unusul numerical formats. For example, if you set Windows language to US English and leave numerical formats at their default settings,
1,234,567.89 is understood to be one million, ... point eighty nine

but it you happened to enter data using the (most of) European standard
1.234.567,89 most programs will either balk or interpret this as a string of text. The latter is what excel does. If you then try to operate on it, excel complains.

So far, nothing too bad as long as the user has the correct language set for whatever he/she wants to use as a numerical format.

Now, let's move to VBA and consider a similar situation, i.e., language is set to US English and the user enters a number into a form text box using the European format. Unless the code knows what is happening, the results are likely to be incorrect. It is certainly possible to tell the user what format is expected, but that breaks down if the procedure is, say, pulling a "number" out of a table.

So, is there some way to fetch the op/sys language and user specified formats for numbers? Is there a file property in Word that "remembers" the opsys language when the file was created?

Is there a VBA procedure already written that handles this problem. I envision a procedure that has accepts a character string representing some number in Language1 format and spits it back out as a character string in Language2 format.

Thanks