jiada
asked on
Urgent! How to change the Regional setting???
Hi experts,
Please help!
How to change the Regional setting like the one in Control Panel>Regional Settings
eg: from English UK to English US by using VB4.
Source code needed urgently.
Program should performs well on win98 and NT4 workstation.
Please help!
How to change the Regional setting like the one in Control Panel>Regional Settings
eg: from English UK to English US by using VB4.
Source code needed urgently.
Program should performs well on win98 and NT4 workstation.
ASKER
Hi thanks. But this is not the one I need.
Or the better way to describe my question is ...
How can I know and change the windows system language (eg: from French to English US) in a multi-language support windows by using VB. Like the same thing we can do manually in Control Panel> Regional Settings>[select your target language].
Or the better way to describe my question is ...
How can I know and change the windows system language (eg: from French to English US) in a multi-language support windows by using VB. Like the same thing we can do manually in Control Panel> Regional Settings>[select your target language].
I grabbed this from somewhere on the web (sorry I can not rememeber where exactly) - but it works well to display and set all the regional settings.
'Place in Module
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
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" ()
Public Const LOCALE_ICENTURY = &H24
Public Const LOCALE_ICOUNTRY = &H5
Public Const LOCALE_ICURRDIGITS = &H19
Public Const LOCALE_ICURRENCY = &H1B
Public Const LOCALE_IDATE = &H21
Public Const LOCALE_IDAYLZERO = &H26
Public Const LOCALE_IDEFAULTCODEPAGE = &HB
Public Const LOCALE_IDEFAULTCOUNTRY = &HA
Public Const LOCALE_IDEFAULTLANGUAGE = &H9
Public Const LOCALE_IDIGITS = &H11
Public Const LOCALE_IINTLCURRDIGITS = &H1A
Public Const LOCALE_ILANGUAGE = &H1
Public Const LOCALE_ILDATE = &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 LOCALE_S1159 = &H28
Public Const LOCALE_S2359 = &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 = &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 = &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 = &HF
Public Const LOCALE_STIME = &H1E
Public Const LOCALE_STIMEFORMAT = &H1003
'End of Module Code
'For you Form1, just add a command button to display the settings. Set_locale is a routine to change individual parameters of the regional settings. You will have to modify that for whichever setting you are looking for.
Private Sub Command1_Click()
Get_locale
End Sub
Private Sub Get_locale() ' 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 just change the contant in the Function
iRet1 = GetLocaleInfo(Locale, LOCALE_SCOUNTRY, lpLCDataVar, 0)
Symbol = String$(iRet1, 0)
iRet2 = GetLocaleInfo(Locale, LOCALE_SCOUNTRY, Symbol, iRet1)
Pos = InStr(Symbol, Chr$(0))
If Pos > 0 Then
Symbol = Left$(Symbol, Pos - 1)
MsgBox "Regional Setting = " + Symbol
End If
End Sub
Private Sub Set_locale() 'Change the regional setting
Dim Symbol As String
Dim iRet As Long
Dim Locale As Long
'LOCALE_SDATE is the constant for the date separator
'as stated in declarations
'for any other locale just change the contant in the Function
Locale = GetUserDefaultLCID() 'Get user Locale ID
Symbol = "-" 'New character for the locale
iRet = SetLocaleInfo(Locale, LOCALE_SDATE, Symbol)
End Sub
Hope this helps!
'Place in Module
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
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" ()
Public Const LOCALE_ICENTURY = &H24
Public Const LOCALE_ICOUNTRY = &H5
Public Const LOCALE_ICURRDIGITS = &H19
Public Const LOCALE_ICURRENCY = &H1B
Public Const LOCALE_IDATE = &H21
Public Const LOCALE_IDAYLZERO = &H26
Public Const LOCALE_IDEFAULTCODEPAGE = &HB
Public Const LOCALE_IDEFAULTCOUNTRY = &HA
Public Const LOCALE_IDEFAULTLANGUAGE = &H9
Public Const LOCALE_IDIGITS = &H11
Public Const LOCALE_IINTLCURRDIGITS = &H1A
Public Const LOCALE_ILANGUAGE = &H1
Public Const LOCALE_ILDATE = &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 LOCALE_S1159 = &H28
Public Const LOCALE_S2359 = &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 = &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 = &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 = &HF
Public Const LOCALE_STIME = &H1E
Public Const LOCALE_STIMEFORMAT = &H1003
'End of Module Code
'For you Form1, just add a command button to display the settings. Set_locale is a routine to change individual parameters of the regional settings. You will have to modify that for whichever setting you are looking for.
Private Sub Command1_Click()
Get_locale
End Sub
Private Sub Get_locale() ' 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 just change the contant in the Function
iRet1 = GetLocaleInfo(Locale, LOCALE_SCOUNTRY, lpLCDataVar, 0)
Symbol = String$(iRet1, 0)
iRet2 = GetLocaleInfo(Locale, LOCALE_SCOUNTRY, Symbol, iRet1)
Pos = InStr(Symbol, Chr$(0))
If Pos > 0 Then
Symbol = Left$(Symbol, Pos - 1)
MsgBox "Regional Setting = " + Symbol
End If
End Sub
Private Sub Set_locale() 'Change the regional setting
Dim Symbol As String
Dim iRet As Long
Dim Locale As Long
'LOCALE_SDATE is the constant for the date separator
'as stated in declarations
'for any other locale just change the contant in the Function
Locale = GetUserDefaultLCID() 'Get user Locale ID
Symbol = "-" 'New character for the locale
iRet = SetLocaleInfo(Locale, LOCALE_SDATE, Symbol)
End Sub
Hope this helps!
Try this:
In a module
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
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" ()
Public Const LOCALE_SLANGUAGE = &H2
In your form
Public Sub Get_locale()
Dim Clang As String
Dim iRet1 As Long
Dim iRet2 As Long
Dim lpLCDataVar As String
Dim Pos As Integer
Dim Locale As Long
Locale = GetUserDefaultLCID()
iRet1 = GetLocaleInfo(Locale, LOCALE_SLANGUAGE, _
lpLCDataVar, 0)
Clang = String$(iRet1, 0)
iRet2 = GetLocaleInfo(Locale, LOCALE_SLANGUAGE, Clang, iRet1)
Pos = InStr(Clang, Chr$(0))
If Pos > 0 Then
Clang = Left$(Clang, Pos - 1)
MsgBox "Regional Language is " & Clang
End If
End Sub
Public Sub Set_locale()
Dim Nlang As String
Dim iRet As Long
Dim Locale As Long
Locale = GetUserDefaultLCID() 'Get user Locale ID
Nlang = "Put New Language here"
iRet = SetLocaleInfo(Locale, LOCALE_SLANGUAGE, Symbol)
End Sub
In a module
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
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" ()
Public Const LOCALE_SLANGUAGE = &H2
In your form
Public Sub Get_locale()
Dim Clang As String
Dim iRet1 As Long
Dim iRet2 As Long
Dim lpLCDataVar As String
Dim Pos As Integer
Dim Locale As Long
Locale = GetUserDefaultLCID()
iRet1 = GetLocaleInfo(Locale, LOCALE_SLANGUAGE, _
lpLCDataVar, 0)
Clang = String$(iRet1, 0)
iRet2 = GetLocaleInfo(Locale, LOCALE_SLANGUAGE, Clang, iRet1)
Pos = InStr(Clang, Chr$(0))
If Pos > 0 Then
Clang = Left$(Clang, Pos - 1)
MsgBox "Regional Language is " & Clang
End If
End Sub
Public Sub Set_locale()
Dim Nlang As String
Dim iRet As Long
Dim Locale As Long
Locale = GetUserDefaultLCID() 'Get user Locale ID
Nlang = "Put New Language here"
iRet = SetLocaleInfo(Locale, LOCALE_SLANGUAGE, Symbol)
End Sub
ASKER
Hi,
It doesn't work! please help again!
All the proposed solution above is to get the current locale GetUserDefaultLCID() and changing its' sub information SetLocaleInfo().
What I urgently need is to change the system default locale(language) without changing any sub information for that specific locale.
I would be much appreciate if somebody can help on this.
Regards.
It doesn't work! please help again!
All the proposed solution above is to get the current locale GetUserDefaultLCID() and changing its' sub information SetLocaleInfo().
What I urgently need is to change the system default locale(language) without changing any sub information for that specific locale.
I would be much appreciate if somebody can help on this.
Regards.
This question appears to have been abandoned. A question regarding will be left in the Community Support area regarding its disposition; if you have any comment about the question, please leave it there.
A moderator will be asked to resolve the question. The recommendation will be to refund the points and move the question to the PAQ.
The link to the Community Support area is:
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
DO NOT ACCEPT THIS COMMENT AS AN ANSWER.
Regards,
ep
A moderator will be asked to resolve the question. The recommendation will be to refund the points and move the question to the PAQ.
The link to the Community Support area is:
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
DO NOT ACCEPT THIS COMMENT AS AN ANSWER.
Regards,
ep
ASKER
Hi experts,
Thanks for all your hard work on this question.
I decide to delete off this question since I put this question as 'urgent' about one year ago. The answer now is no more important to me as my project deadline is long away expired.
Kindly consider the above mentioned situation and allow me to delete off this question. Thanks.
jiada
Thanks for all your hard work on this question.
I decide to delete off this question since I put this question as 'urgent' about one year ago. The answer now is no more important to me as my project deadline is long away expired.
Kindly consider the above mentioned situation and allow me to delete off this question. Thanks.
jiada
ASKER
Thanks ep for your reminder as this question is really been abandoned.
Regards,
jiada
Regards,
jiada
oops!, my comment has dissapeared!
:(
:(
jiada,
No problem... thanks for giving us some resolution.
Richie,
What... and after only a year you can't remember what you wrote? *grin*
Regards, and happy holidays,
ep
No problem... thanks for giving us some resolution.
Richie,
What... and after only a year you can't remember what you wrote? *grin*
Regards, and happy holidays,
ep
No problem, just a comment...:)
Same to you!!
Same to you!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Step-by-Step Example
In a new or existing project, add a form (Form1).
Add a CommandButton (Command1) to the form.
Add the following code to the General Declarations section of Form1:
Option Explicit
Private Const LOCALE_SSHORTDATE = &H1F
Private Const WM_SETTINGCHANGE = &H1A
'same as the old WM_WININICHANGE
Private Const HWND_BROADCAST = &HFFFF&
Private Declare Function SetLocaleInfo Lib "kernel32" Alias _
"SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As _
Long, ByVal lpLCData As String) As Boolean
Private 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
Private Declare Function GetSystemDefaultLCID Lib "kernel32" _
() As Long
Place the following code in Command1_Click event procedure:
P Private Sub Command1_Click()
Dim dwLCID As Long
dwLCID = GetSystemDefaultLCID()
If SetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, "dd-MMM-yy") _
= False Then
MsgBox "Failed"
Exit Sub
End If
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0
End Sub
Run the program and open the form. Click on Command1 and then exit the program.
Go to Control Panel and double-click on the Regional Settings icon. Select the Date tab. Note that the Short date style has been changed to "dd-MMM-yy."