Number format and regional settings
Author |
Message |
Alex Dybenk #1 / 10
|
 Number format and regional settings
Hello I use Eval function in my programm to calculate expressions. if i use USA settings for number (1,234.56) all things work ok. if i use other number settings, eg. 1.234,56 VBA can't evaluate this and generate error. Is it any function in Access which convert number to string in VBA format? i tried format, str, cstr - all them output numbers in format, defined in regional settings Thank you. -- Best regards, ___________ Alex Dybenko Point Limited
Home Page: http://www.*-*-*.com/ Moscow MS Access User Group, chairman http://www.*-*-*.com/
|
Fri, 01 Sep 2000 03:00:00 GMT |
|
 |
Dev Ashis #2 / 10
|
 Number format and regional settings
Hi Alex, I don't know of a direct way since (if I'm right) Access gets these directly from registry. However, it should be possible to set the appropriate Locale Info in the registry before evaluating your expressions. For example, something along these lines if fLocaleInfo(LOCALE_SDECIMAL)="." Then fSuccess= LocaleInfoSet(LOCALE_SDECIMAL,",") end if and then reset the LOCALE_SDECIMAL and others to original values once you're done. If I missed something that's much simpler, I apologize (haven't had any 'real' experience with this) ... (I'm using LocaleInfoSet function provided by Terry Kreft as I haven't written my own corressponding one yet. Thanks Terry. :-) ) Public Const LOCALE_ILANGUAGE = &H1 ' language id Public Const LOCALE_SLANGUAGE = &H2 ' localized name of language Public Const LOCALE_SENGLANGUAGE = &H1001 ' English name of language Public Const LOCALE_SABBREVLANGNAME = &H3 ' abbreviated language name Public Const LOCALE_SNATIVELANGNAME = &H4 ' native name of language Public Const LOCALE_ICOUNTRY = &H5 ' country code Public Const LOCALE_SCOUNTRY = &H6 ' localized name of country Public Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country Public Const LOCALE_SABBREVCTRYNAME = &H7 ' abbreviated country name Public Const LOCALE_SNATIVECTRYNAME = &H8 ' native name of country Public Const LOCALE_IDEFAULTLANGUAGE = &H9 ' default language id Public Const LOCALE_IDEFAULTCOUNTRY = &HA ' default country code Public Const LOCALE_IDEFAULTCODEPAGE = &HB ' default code page Public Const LOCALE_SLIST = &HC ' list item separator Public Const LOCALE_IMEASURE = &HD ' 0 = metric, 1 = US Public Const LOCALE_SDECIMAL = &HE ' decimal separator Public Const LOCALE_STHOUSAND = &HF ' thousand separator Public Const LOCALE_SGROUPING = &H10 ' digit grouping Public Const LOCALE_IDIGITS = &H11 ' number of fractional digits Public Const LOCALE_ILZERO = &H12 ' leading zeros for decimal Public Const LOCALE_SNATIVEDIGITS = &H13 ' native ascii 0-9 Public Const LOCALE_SCURRENCY = &H14 ' local monetary symbol Public Const LOCALE_SINTLSYMBOL = &H15 ' intl monetary symbol Public Const LOCALE_SMONDECIMALSEP = &H16 ' monetary decimal separator Public Const LOCALE_SMONTHOUSANDSEP = &H17 ' monetary thousand separator Public Const LOCALE_SMONGROUPING = &H18 ' monetary grouping Public Const LOCALE_ICURRDIGITS = &H19 ' # local monetary digits Public Const LOCALE_IINTLCURRDIGITS = &H1A ' # intl monetary digits Public Const LOCALE_ICURRENCY = &H1B ' positive currency mode Public Const LOCALE_INEGCURR = &H1C ' negative currency mode Public Const LOCALE_SDATE = &H1D ' date separator Public Const LOCALE_STIME = &H1E ' time separator Public Const LOCALE_SSHORTDATE = &H1F ' short date format string Public Const LOCALE_SLONGDATE = &H20 ' long date format string Public Const LOCALE_STIMEFORMAT = &H1003 ' time format string Public Const LOCALE_IDATE = &H21 ' short date format ordering Public Const LOCALE_ILDATE = &H22 ' long date format ordering Public Const LOCALE_ITIME = &H23 ' time format specifier Public Const LOCALE_ICENTURY = &H24 ' century format specifier Public Const LOCALE_ITLZERO = &H25 ' leading zeros in time field Public Const LOCALE_IDAYLZERO = &H26 ' leading zeros in day field Public Const LOCALE_IMONLZERO = &H27 ' leading zeros in month field Public Const LOCALE_S1159 = &H28 ' AM designator Public Const LOCALE_S2359 = &H29 ' PM designator Public Const LOCALE_SDAYNAME1 = &H2A ' long name for Monday Public Const LOCALE_SDAYNAME2 = &H2B ' long name for Tuesday Public Const LOCALE_SDAYNAME3 = &H2C ' long name for Wednesday Public Const LOCALE_SDAYNAME4 = &H2D ' long name for Thursday Public Const LOCALE_SDAYNAME5 = &H2E ' long name for Friday Public Const LOCALE_SDAYNAME6 = &H2F ' long name for Saturday Public Const LOCALE_SDAYNAME7 = &H30 ' long name for Sunday Public Const LOCALE_SABBREVDAYNAME1 = &H31 ' abbreviated name for Monday Public Const LOCALE_SABBREVDAYNAME2 = &H32 ' abbreviated name for Tuesday Public Const LOCALE_SABBREVDAYNAME3 = &H33 ' abbreviated name for Wednesday Public Const LOCALE_SABBREVDAYNAME4 = &H34 ' abbreviated name for Thursday Public Const LOCALE_SABBREVDAYNAME5 = &H35 ' abbreviated name for Friday Public Const LOCALE_SABBREVDAYNAME6 = &H36 ' abbreviated name for Saturday Public Const LOCALE_SABBREVDAYNAME7 = &H37 ' abbreviated name for Sunday Public Const LOCALE_SMONTHNAME1 = &H38 ' long name for January Public Const LOCALE_SMONTHNAME2 = &H39 ' long name for February Public Const LOCALE_SMONTHNAME3 = &H3A ' long name for March Public Const LOCALE_SMONTHNAME4 = &H3B ' long name for April Public Const LOCALE_SMONTHNAME5 = &H3C ' long name for May Public Const LOCALE_SMONTHNAME6 = &H3D ' long name for June Public Const LOCALE_SMONTHNAME7 = &H3E ' long name for July Public Const LOCALE_SMONTHNAME8 = &H3F ' long name for August Public Const LOCALE_SMONTHNAME9 = &H40 ' long name for September Public Const LOCALE_SMONTHNAME10 = &H41 ' long name for October Public Const LOCALE_SMONTHNAME11 = &H42 ' long name for November Public Const LOCALE_SMONTHNAME12 = &H43 ' long name for December Public Const LOCALE_SABBREVMONTHNAME1 = &H44 ' abbreviated name for January Public Const LOCALE_SABBREVMONTHNAME2 = &H45 ' abbreviated name for February Public Const LOCALE_SABBREVMONTHNAME3 = &H46 ' abbreviated name for March Public Const LOCALE_SABBREVMONTHNAME4 = &H47 ' abbreviated name for April Public Const LOCALE_SABBREVMONTHNAME5 = &H48 ' abbreviated name for May Public Const LOCALE_SABBREVMONTHNAME6 = &H49 ' abbreviated name for June Public Const LOCALE_SABBREVMONTHNAME7 = &H4A ' abbreviated name for July Public Const LOCALE_SABBREVMONTHNAME8 = &H4B ' abbreviated name for August Public Const LOCALE_SABBREVMONTHNAME9 = &H4C ' abbreviated name for September Public Const LOCALE_SABBREVMONTHNAME10 = &H4D ' abbreviated name for October Public Const LOCALE_SABBREVMONTHNAME11 = &H4E ' abbreviated name for November Public Const LOCALE_SABBREVMONTHNAME12 = &H4F ' abbreviated name for December Public Const LOCALE_SABBREVMONTHNAME13 = &H100F Public Const LOCALE_SNEGATIVESIGN& = &H51 Public Const LOCALE_SPOSITIVESIGN& = &H50 Public Const LOCALE_SYSTEM_DEFAULT& = &H800 Public Const LOCALE_USER_DEFAULT& = &H400 Const cMAXLEN = 255 Private Declare Function apiGetLocaleInfo Lib "kernel32" _ Alias "GetLocaleInfoA" _ (ByVal Locale As Long, _ ByVal LCType As Long, _ ByVal lpLCData As String, _ ByVal cchData As Long) _ As Long Private Declare Function apiSetLocaleInfo Lib "kernel32" _ Alias "SetLocaleInfoA" _ (ByVal Locale As Long, _ ByVal LCType As Long, _ ByVal lpLCData As String) _ As Long Function fLocaleInfo(lngLCType As Long) As String Dim lngLocale As Long Dim strLCData As String, lngData As Long Dim lngx As Long strLCData = String$(cMAXLEN - 1, 0) lngData = cMAXLEN lngx = apiGetLocaleInfo(LOCALE_USER_DEFAULT, lngLCType, _ strLCData, lngData) If lngx <> 0 Then fLocaleInfo = Left$(strLCData, lngx - 1) End If End Function Function LocaleInfoSet(LCType As Long, lpLCData As String) As Boolean 'Courtesy of Terry Kreft Dim lngRet As Long Dim Locale As Long Const LCType_ALLOWED = LOCALE_SDATE Or LOCALE_ICURRDIGITS _ Or LOCALE_SDECIMAL Or LOCALE_ICURRENCY Or LOCALE_SGROUPING Or LOCALE_IDIGITS _ Or LOCALE_SLIST Or LOCALE_SLONGDATE Or _ LOCALE_SMONDECIMALSEP Or LOCALE_ILZERO _ Or LOCALE_SMONGROUPING Or LOCALE_IMEASURE Or LOCALE_SMONTHOUSANDSEP Or _ LOCALE_INEGCURR Or LOCALE_SNEGATIVESIGN Or _ LOCALE_SPOSITIVESIGN Or LOCALE_ITIME Or LOCALE_SSHORTDATE Or LOCALE_S1159 _ Or LOCALE_STHOUSAND Or LOCALE_S2359 Or LOCALE_STIME Or LOCALE_SCURRENCY _ Or LOCALE_STIMEFORMAT 'Constants not defined Or LOCALE_ICALENDARTYPE Or 'LOCALE_IFIRSTDAYOFWEEK Or LOCALE_IFIRSTWEEKOFYEAR Or LOCALE_INEGNUMBER If (LCType And LCType_ALLOWED) = LCType Then Locale = LOCALE_SYSTEM_DEFAULT lngRet = apiSetLocaleInfo(Locale, LCType, lpLCData) End If LocaleInfoSet = lngRet * -1 End Function -- Just my $.001 Please limit questions to newsgroups only! Dev Ashish --------------- The Access Web ( http://home.att.net/~dashish ) ---------------
:Hello :I use Eval function in my programm to calculate expressions. if i use USA :settings for number (1,234.56) all things work ok. if i use other number :settings, eg. 1.234,56 VBA can't evaluate this and generate error. Is it any :function in Access which convert number to string in VBA format? i tried :format, str, cstr - all them output numbers in format, defined in regional :settings :Thank you. :-- :Best regards, :___________ :Alex Dybenko :Point Limited
:Home Page: http://www.geocities.com/SiliconValley/Heights/5091/ :Moscow MS Access User Group, chairman :http://www.arimsoft.ru/msaccess : :
|
Fri, 01 Sep 2000 03:00:00 GMT |
|
 |
Alex Dybenk #3 / 10
|
 Number format and regional settings
Hi Dev, thanks a lot to you and Terry. I also thought about this way, but i hope there is can be more easy way. -Alex Quote:
>Hi Alex, >I don't know of a direct way since (if I'm right) Access gets these directly >from registry. However, it should be possible to set the appropriate Locale >Info in the registry before evaluating your expressions. For example, >something along these lines >if fLocaleInfo(LOCALE_SDECIMAL)="." Then > fSuccess= LocaleInfoSet(LOCALE_SDECIMAL,",") >end if >and then reset the LOCALE_SDECIMAL and others to original values once you're >done. If I missed something that's much simpler, I apologize (haven't had >any 'real' experience with this) ...
|
Fri, 01 Sep 2000 03:00:00 GMT |
|
 |
Michel Wals #4 / 10
|
 Number format and regional settings
Hi, Just a note, cannot Set the locale under W95, only under NT. Under W95, you can only Get the locale info. Set doesn't "error", but doesn't "do" either... (unless I am missing something...) Sure, if you are using NT.... Vanderghast, Access MVP.
|
Sat, 02 Sep 2000 03:00:00 GMT |
|
 |
Alex Dybenk #5 / 10
|
 Number format and regional settings
Michel, thank you for info As there is no better solutions, i will read locale settings and and replace locale decimal with "." in evaluating string and so on -Alex Quote:
>Hi, >Just a note, cannot Set the locale under W95, only under NT. Under W95, you >can only Get the locale info. Set doesn't "error", but doesn't "do" >either... (unless I am missing something...) Sure, if you are using NT.... >Vanderghast, Access MVP.
|
Sat, 02 Sep 2000 03:00:00 GMT |
|
 |
Dev Ashis #6 / 10
|
 Number format and regional settings
Quote:
>Hi, >Just a note, cannot Set the locale under W95, only under NT. Under W95, you >can only Get the locale info. Set doesn't "error", but doesn't "do" >either... (unless I am missing something...) Sure, if you are using NT.... >Vanderghast, Access MVP.
Hi Michel, Thanks for that bit of info. I wasn't aware of it. (Hmmm.. Maybe I should cut down on {trying to} write APIs at work {NT} ) If possible, can you please direct this API newbie to a source which lists these "API exceptions" between Win95 & NT? Thanks Dev -- Please limit questions to newsgroups only... Just my $.001 Dev Ashish --------------- The Access Web ( http://home.att.net/~dashish ) ---------------
|
Sat, 02 Sep 2000 03:00:00 GMT |
|
 |
Michel Wals #7 / 10
|
 Number format and regional settings
Hi, Exceptions? Well, quite hard. Just take a look at the doc. on that specific subject (Set Locale info): some articles say W95 support it, some won't list W95 under the same info. Just have to guess in those case that W95 won't crach, but won't "do" either. But since Windows 98 doesn't seem to be highly recommended anymore (except for home), I am just waiting for NT 5. Quote:
(...) >If possible, can you please direct this API newbie to a source which lists >these "API exceptions" between Win95 & NT? >Thanks >Dev >-- >Please limit questions to newsgroups only... >Just my $.001 >Dev Ashish >--------------- >The Access Web ( http://home.att.net/~dashish ) >---------------
|
Sun, 03 Sep 2000 03:00:00 GMT |
|
 |
Michel Wals #8 / 10
|
 Number format and regional settings
Hi, For dates I always use Format( , "\#mm/dd/yyyy\#") and so automatic formatting is not a problem. Harder is the numerical automatic conversion that sprout arguements while I am wanting decimal dot: 2.2 becoming 2,2 if using automatic data conversion ( the , being a list separator, that brings two arguments instead of a single one intended). And no formatting I know will solve the problem as soon as you use decimal number (not only for Eval, but for SQL statement written on the fly and Dxxxx criteria functions too). So either I read the locale and refuse to continue unless the end user change it for US, either I change all my: " " & DecimalNumber & " " with " " & ChangeToUS(DecimalNumber) & " " where ChangeToUS first convert to a string, then parse the string to replace the decimal separator to a dot (When the client REFUSE to be forced to use US setting... no choice but to do it). Vanderghast, Access MVP.
Quote: >Michel, >thank you for info >As there is no better solutions, i will read locale settings and and replace >locale decimal with "." in evaluating string and so on >-Alex
>>Hi, >>Just a note, cannot Set the locale under W95, only under NT. Under W95, you >>can only Get the locale info. Set doesn't "error", but doesn't "do" >>either... (unless I am missing something...) Sure, if you are using NT.... >>Vanderghast, Access MVP.
|
Sun, 03 Sep 2000 03:00:00 GMT |
|
 |
Dev Ashis #9 / 10
|
 Number format and regional settings
Quote:
>Hi, >Exceptions? Well, quite hard. Just take a look at the doc. on that specific >subject (Set Locale info): some articles say W95 support it, some won't list >W95 under the same info. Just have to guess in those case that W95 won't >crach, but won't "do" either. But since Windows 98 doesn't seem to be highly >recommended anymore (except for home), I am just waiting for NT 5.
Hi Michel, Thanks for your response. I thought I looked at SetLocaleInfo in Dan Appleman's book and didn't find any mention of this. But i might have missed something. I guess most of this is trial and error. Thanks Dev -- Please limit questions to newsgroups only... Just my $.001 Dev Ashish --------------- The Access Web ( http://home.att.net/~dashish ) ---------------
|
Sun, 03 Sep 2000 03:00:00 GMT |
|
 |
Michel Wals #10 / 10
|
 Number format and regional settings
Ha, Me, I was refering to the online help in Visual Studio. There is always a list of supporting OS, for each of the API, and the list is more or less repeated by subject too. Vanderghast, Access MVP. Quote:
>Hi Michel, >Thanks for your response. >I thought I looked at SetLocaleInfo in Dan Appleman's book and didn't find >any mention of this. But i might have missed something. >I guess most of this is trial and error. >Thanks >Dev >-- >Please limit questions to newsgroups only... >Just my $.001 >Dev Ashish >--------------- >The Access Web ( http://home.att.net/~dashish ) >---------------
|
Mon, 04 Sep 2000 03:00:00 GMT |
|
|
|