Home All Groups Group Topic Archive Search About

Problem reading Digit Grouping Symbol

Author
27 Nov 2007 3:38 PM
Chris
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!

Author
27 Nov 2007 4:12 PM
Rick Rothstein (MVP - VB)
>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
Author
28 Nov 2007 9:22 AM
Chris
Thanks a lot Rick for your message. The thousands separator works in
my case.
Author
27 Nov 2007 9:56 PM
Karl E. Peterson
Chris wrote:
Show 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
Author
28 Nov 2007 9:16 AM
Chris
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

AddThis Social Bookmark Button