469,344 Members | 6,139 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Problem reading Digit Grouping Symbol

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!
Nov 27 '07 #1
4 3485
>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

Nov 27 '07 #2
Chris wrote:
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
Nov 27 '07 #3

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
Nov 28 '07 #4

Thanks a lot Rick for your message. The thousands separator works in
my case.
Nov 28 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

68 posts views Thread by Marco Bubke | last post: by
6 posts views Thread by Henry Jordon | last post: by
1 post views Thread by BigMan | last post: by
1 post views Thread by Luis Lanuza | last post: by
6 posts views Thread by efrenba | last post: by
reply views Thread by Roman Bertle | last post: by
1 post views Thread by brad | last post: by
5 posts views Thread by John Ztwin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.