Solved

Check (and change) the decimal symbol in Regional Settings

Posted on 2003-11-24
6
846 Views
Last Modified: 2010-05-18
I need to check (and eventually change) which decimal symbol has my end-user defined in the control panel / regional settings.

Please help me.
0
Comment
Question by:oso141285
  • 3
6 Comments
 

Expert Comment

by:aHBe
Comment Utility
Check on mid(format(1.2,"0.0"),2,1)="." then you'll know
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
Comment Utility
0
 

Author Comment

by:oso141285
Comment Utility
Richie, the code you are pointing at PlanetSource seems great. But is not working with my WIN XP - Spanish - Costa Rica.

Trying to understand the code I see the LOCALE_SDECIMAL = &HE and LOCALE_STHOUSAND = &HF have their values correct (by comparision with the FreeVbCode reference)

It seems to always show the opossite.  The code for setting is OK. I would like to know what's wrong.

Thanks in advance.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
I have OS in spanish too and it works with no problems.
Follow is the complete code that i use in a module to chnage decimal and thousand symbols:

Option Explicit

Private 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

Private Declare Function SetLocaleInfo Lib "kernel32" Alias _
    "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, _
    ByVal lpLCData As String) As Boolean

Declare Function GetUserDefaultLCID% Lib "kernel32" ()

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&
Public Const WM_WININICHANGE = &H1A

Public Const LOCALE_ICENTURY As Long = &H24
Public Const LOCALE_ICOUNTRY  As Long = &H5
Public Const LOCALE_ICURRDIGITS  As Long = &H19
Public Const LOCALE_ICURRENCY  As Long = &H1B
Public Const LOCALE_IDATE  As Long = &H21
Public Const LOCALE_IDAYLZERO  As Long = &H26
Public Const LOCALE_IDEFAULTCODEPAGE  As Long = &HB
Public Const LOCALE_IDEFAULTCOUNTRY  As Long = &HA
Public Const LOCALE_IDEFAULTLANGUAGE  As Long = &H9
Public Const LOCALE_IDIGITS  As Long = &H11
Public Const LOCALE_IINTLCURRDIGITS  As Long = &H1A
Public Const LOCALE_ILANGUAGE  As Long = &H1
Public Const LOCALE_ILDATE  As Long = &H22
Public Const LOCALE_ILZERO = &H12
Public Const LOCALE_IMEASURE = &HD
Public Const LOCALE_IMONLZERO = &H27
Public Const LOCALE_INEGCURR = &H1C
Public Const LOCALE_INEGSEPBYSPACE = &H57
Public Const LOCALE_INEGSIGNPOSN = &H53
Public Const LOCALE_INEGSYMPRECEDES = &H56
Public Const LOCALE_IPOSSEPBYSPACE = &H55
Public Const LOCALE_IPOSSIGNPOSN = &H52
Public Const LOCALE_IPOSSYMPRECEDES = &H54
Public Const LOCALE_ITIME = &H23
Public Const LOCALE_ITLZERO = &H25
Public Const LOCALE_NOUSEROVERRIDE = &H80000000
Public Const SymbolAM = &H28
Public Const SymbolPM = &H29
Public Const LOCALE_SABBREVCTRYNAME = &H7
Public Const LOCALE_SABBREVDAYNAME1 = &H31
Public Const LOCALE_SABBREVDAYNAME2 = &H32
Public Const LOCALE_SABBREVDAYNAME3 = &H33
Public Const LOCALE_SABBREVDAYNAME4 = &H34
Public Const LOCALE_SABBREVDAYNAME5 = &H35
Public Const LOCALE_SABBREVDAYNAME6 = &H36
Public Const LOCALE_SABBREVDAYNAME7 = &H37
Public Const LOCALE_SABBREVLANGNAME = &H3
Public Const LOCALE_SABBREVMONTHNAME1 = &H44
Public Const LOCALE_SCOUNTRY = &H6
Public Const LOCALE_SCURRENCY = &H14
Public Const LOCALE_SDATE = &H1D
Public Const LOCALE_SDAYNAME1 = &H2A
Public Const LOCALE_SDAYNAME2 = &H2B
Public Const LOCALE_SDAYNAME3 = &H2C
Public Const LOCALE_SDAYNAME4 = &H2D
Public Const LOCALE_SDAYNAME5 = &H2E
Public Const LOCALE_SDAYNAME6 = &H2F
Public Const LOCALE_SDAYNAME7 = &H30
Public Const LOCALE_SDECIMAL  As Long = &HE
Public Const LOCALE_SENGCOUNTRY = &H1002
Public Const LOCALE_SENGLANGUAGE = &H1001
Public Const LOCALE_SGROUPING = &H10
Public Const LOCALE_SINTLSYMBOL = &H15
Public Const LOCALE_SLANGUAGE = &H2
Public Const LOCALE_SLIST  As Long = &HC
Public Const LOCALE_SLONGDATE = &H20
Public Const LOCALE_SMONDECIMALSEP = &H16
Public Const LOCALE_SMONGROUPING = &H18
Public Const LOCALE_SMONTHNAME1 = &H38
Public Const LOCALE_SMONTHNAME10 = &H41
Public Const LOCALE_SMONTHNAME11 = &H42
Public Const LOCALE_SMONTHNAME12 = &H43
Public Const LOCALE_SMONTHNAME2 = &H39
Public Const LOCALE_SMONTHNAME3 = &H3A
Public Const LOCALE_SMONTHNAME4 = &H3B
Public Const LOCALE_SMONTHNAME5 = &H3C
Public Const LOCALE_SMONTHNAME6 = &H3D
Public Const LOCALE_SMONTHNAME7 = &H3E
Public Const LOCALE_SMONTHNAME8 = &H3F
Public Const LOCALE_SMONTHNAME9 = &H40
Public Const LOCALE_SMONTHOUSANDSEP = &H17
Public Const LOCALE_SNATIVECTRYNAME = &H8
Public Const LOCALE_SNATIVEDIGITS = &H13
Public Const LOCALE_SNATIVELANGNAME = &H4
Public Const LOCALE_SNEGATIVESIGN = &H51
Public Const LOCALE_SPOSITIVESIGN = &H50
Public Const LOCALE_SSHORTDATE = &H1F
Public Const LOCALE_STHOUSAND  As Long = &HF
Public Const LOCALE_STIME = &H1E
Public Const LOCALE_STIMEFORMAT = &H1003

Public Function Get_locale(ByVal RSValue As Long) ' Retrieve the regional setting
      Dim Symbol As String
      Dim iRet1 As Long
      Dim iRet2 As Long
      Dim lpLCDataVar As String
      Dim Pos As Integer
      Dim Locale As Long
     
      Locale = GetUserDefaultLCID()

'LOCALE_SDATE is the constant for the date separator
'as stated in declarations
'for any other locale setting just change the constant

'Function can also be re-written to take the
'locale symbol being requested as a parameter
     
      iRet1 = GetLocaleInfo(Locale, RSValue, _
      lpLCDataVar, 0)
      Symbol = String$(iRet1, 0)
     
      iRet2 = GetLocaleInfo(Locale, RSValue, Symbol, iRet1)
      Pos = InStr(Symbol, Chr$(0))
      If Pos > 0 Then
           Symbol = Left$(Symbol, Pos - 1)
           Get_locale = Symbol
      End If

End Function

Public Function Set_locale(ByVal RSValue As Long, Symbol As String) 'Change the regional setting
      Dim iRet As Long
      Dim Locale As Long
      Locale = GetUserDefaultLCID() 'Get user Locale ID
      iRet = SetLocaleInfo(Locale, RSValue, Symbol)
End Function

Public Sub Anounce_locale_change()
PostMessage HWND_BROADCAST, WM_WININICHANGE, 0, 0
End Sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now