dbTalk Databases Forums  

Problem reading Digit Grouping Symbol

comp.databases.ms-access comp.databases.ms-access


Discuss Problem reading Digit Grouping Symbol in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris
 
Posts: n/a

Default Problem reading Digit Grouping Symbol - 11-27-2007 , 09:38 AM






I tried to retrieve the digit grouping symbol in MSAccess but
unfortunately 3;0 is retrieved instead of comma which is my symbol.
Function retrieves decimal symbol and list separator without any
problem.

I used the code below:

var_char_copied = GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_SGROUPING, var_SYSTEM_DTG, Len(var_SYSTEM_DTG))

If var_char_copied > 0 Then
var_SYSTEM_DTG = Trim(Mid(var_SYSTEM_DTG, 1, var_char_copied))
End If

Declare Function GetLocaleInfo Lib "kernel32" Alias
"GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal
lpLCData As String, ByVal cchData As Long) As Long

Public Const LOCALE_SDECIMAL = &HE ' decimal separator
Public Const LOCALE_SLIST = &HC ' list item separator
Public Const LOCALE_SGROUPING = &H10 ' digit grouping
Public Const LOCALE_USER_DEFAULT As Long = 0

Thanks a lot in advance!

Reply With Quote
  #2  
Old   
Rick Rothstein \(MVP - VB\)
 
Posts: n/a

Default Re: Problem reading Digit Grouping Symbol - 11-27-2007 , 10:12 AM






Quote:
I tried to retrieve the digit grouping symbol in MSAccess but
unfortunately 3;0 is retrieved instead of comma which is my symbol.
Function retrieves decimal symbol and list separator without any
problem.
Here are non-API routines I use to retrieve the various regional setting
symbols and formats (use them exactly as posted, don't try to adjust them in
any way, they are correct as posted)... does the one I use for Thousands
Separator work for you?

DateSeparator = Format$(0, "/")

DecimalPoint = Format$(0, ".")

ThousandsSeparator = Mid$(Format$(1000, "#,###"), 2, 1)

Function DateFormat() As String
DateFormat = CStr(DateSerial(2003, 1, 2))
DateFormat = Replace(DateFormat, "2003", "YYYY")
DateFormat = Replace(DateFormat, "03", "YY")
DateFormat = Replace(DateFormat, "01", "MM")
DateFormat = Replace(DateFormat, "1", "M")
DateFormat = Replace(DateFormat, "02", "dd")
DateFormat = Replace(DateFormat, "2", "d")
DateFormat = Replace(DateFormat, MonthName(1), "MMMM")
DateFormat = Replace(DateFormat, MonthName(1, True), "MMM")
End Function

Function TimeFormat() As String
TimeFormat = CStr(TimeSerial(13, 22, 44))
TimeFormat = Replace(TimeFormat, "22", "mm")
TimeFormat = Replace(TimeFormat, "44", "ss")
If InStr(TimeFormat, "13") > 0 Then
TimeFormat = Replace(TimeFormat, "13", "HH")
If InStr(CStr(TimeSerial(1, 22, 44)), "0") = 0 Then
TimeFormat = Replace(TimeFormat, "HH", "H")
End If
Else
TimeFormat = Replace(TimeFormat, "1", "h")
TimeFormat = Replace(TimeFormat, "0", "h")
TimeFormat = Replace(TimeFormat, "PM", "tt", , , vbTextCompare)
End If
End Function


Rick



Reply With Quote
  #3  
Old   
Karl E. Peterson
 
Posts: n/a

Default Re: Problem reading Digit Grouping Symbol - 11-27-2007 , 03:56 PM



Chris wrote:
Quote:
I tried to retrieve the digit grouping symbol in MSAccess but
unfortunately 3;0 is retrieved instead of comma which is my symbol.
Function retrieves decimal symbol and list separator without any
problem.

I used the code below:

var_char_copied = GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_SGROUPING, var_SYSTEM_DTG, Len(var_SYSTEM_DTG))

If var_char_copied > 0 Then
var_SYSTEM_DTG = Trim(Mid(var_SYSTEM_DTG, 1, var_char_copied))
End If

Declare Function GetLocaleInfo Lib "kernel32" Alias
"GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal
lpLCData As String, ByVal cchData As Long) As Long

Public Const LOCALE_SDECIMAL = &HE ' decimal separator
Public Const LOCALE_SLIST = &HC ' list item separator
Public Const LOCALE_SGROUPING = &H10 ' digit grouping
Public Const LOCALE_USER_DEFAULT As Long = 0

Thanks a lot in advance!
Well, one thing I see wrong is the LOCALE_USER_DEFAULT value (should be &h800).
Another is that you're asking for a list separator, not the digit grouping symbol,
but perhaps that's on purpose and you snipped the wrong code? You don't give enough
information to tell whether the other parameters are correct, or not. (For
instance, are you preallocating a big enough buffer?)

Try this -- http://vb.mvps.org/samples/Locale -- and let me know if it's getting the
wrong value on your system as well.

Thanks... Karl
--
..NET: It's About Trust!
http://vfred.mvps.org




Reply With Quote
  #4  
Old   
Chris
 
Posts: n/a

Default Re: Problem reading Digit Grouping Symbol - 11-28-2007 , 03:16 AM




Thanks Karl for your message.

Parameter LOCALE_USER_DEFAULT or &h800 passed for Locale, return the
same results for decimal, list and grouping symbol. The first 2 are
correct, the grouping symbol is wrong.

With the LOCALE_SGROUPING parameter value I want to retrieve the digit
grouping symbol. The string variable I use for retrieving the value
includes 255 spaces as below:

var_SYSTEM_DTG = Space(255)

var_char_copied = GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_SGROUPING, var_SYSTEM_DTG, Len(var_SYSTEM_DTG))

If var_char_copied > 0 Then
var_SYSTEM_DTG = Trim(Mid(var_SYSTEM_DTG, 1, var_char_copied))
End If

Reply With Quote
  #5  
Old   
Chris
 
Posts: n/a

Default Re: Problem reading Digit Grouping Symbol - 11-28-2007 , 03:22 AM




Thanks a lot Rick for your message. The thousands separator works in
my case.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.