Private Const LOCALE_USER_DEFAULT& = &H400
Private Const LOCALE_SDECIMAL& = &HE
Private Const LOCALE_STHOUSAND& = &HF
Private Declare Function GetLocaleInfo& Lib "kernel32" Alias _
"GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, _
ByVal lpLCData As String, ByVal cchData As Long)
Private Function ThousandSeparator() As String
Dim r As Long, s As String
s = String(10, "a")
r = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, s, 10)
ThousandSeparator = Left$(s, r)
End Function
Private Function DecimalSeparator() As String
Dim r As Long, s As String
s = String(10, "a")
r = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, s, 10)
DecimalSeparator = Left$(s, r)
End Function
Wednesday, December 17, 2008
[vb6] Get the decimal separator and digit grouping symbol
To obtain the current user's settings for the decimal separator and digit grouping symbol, use the GetLocaleInfo function. You can use the same method to retrieve a slurry of other useful information, such as the names of months and days, language, currency format etc.
Subscribe to:
Post Comments (Atom)
Thanks for this code snippit.
ReplyDeleteI made as small correction to remove the trailing NULL character
ThousandSeparator = Left$(s, r-1)
DecimalSeparator = Left$(s, r-1)