Discussion:
How to read system regional settings?
(too old to reply)
BC
2005-08-30 22:17:27 UTC
Permalink
Hi all,

Im working on an asp page that displays currency values. This page
should display the currency in number of decimal places depending on
user system's regional setting (Control\Regional and Language Options).

The question is how can I get the system regional settings with
VBScript?


Cheers,

Benny

*** Sent via Developersdex http://www.developersdex.com ***
Jerold Schulman
2005-08-31 02:04:54 UTC
Permalink
Post by BC
Hi all,
Im working on an asp page that displays currency values. This page
should display the currency in number of decimal places depending on
user system's regional setting (Control\Regional and Language Options).
The question is how can I get the system regional settings with
VBScript?
Cheers,
Benny
*** Sent via Developersdex http://www.developersdex.com ***
See tip 0311 » Regional settings in the registry.
and links in the 'Tips & Tricks' at http://www.jsifaq.com

Dim WshShell, Ndec, sep, grp
Set WshShell = WScript.CreateObject("WScript.Shell")
ndec = WshShell.RegRead("HKCU\Control Panel\International\iCurrDigits")
sep = WshShell.RegRead("HKCU\Control Panel\International\sDecimal")
grp = WshShell.RegRead("HKCU\Control Panel\International\sMonGrouping")
WScript.Echo ndec & " " & sep & " " & grp

In the USA, the defaults for
ndec is 2
sep is .
grp is 3;0
BC
2005-08-31 02:22:35 UTC
Permalink
Hi Jerold,

I was just looking at this when received your message. My codes:
Dim myWScript
Set myWScript = CreateObject("WScript.Shell")
Response.Write "iDigits: " &
myWScript.regread("HKEY_CURRENT_USER\Control
Panel\International\iDigits") & "<br>"
Response.Write "iCurrDigits: " &
myWScript.regread("HKEY_CURRENT_USER\Control
Panel\International\iCurrDigits") & "<br>"

However, this returns me the iDigits and iCurrDigits values from
HKEY_USERS rather than HKEY_CURRENT_USER. Any idea why? I need the
values from HKEY_CURRENT_USER!!!


Cheers,

Benny

*** Sent via Developersdex http://www.developersdex.com ***
Jerold Schulman
2005-08-31 11:25:54 UTC
Permalink
Post by BC
Hi Jerold,
Dim myWScript
Set myWScript = CreateObject("WScript.Shell")
Response.Write "iDigits: " &
myWScript.regread("HKEY_CURRENT_USER\Control
Panel\International\iDigits") & "<br>"
Response.Write "iCurrDigits: " &
myWScript.regread("HKEY_CURRENT_USER\Control
Panel\International\iCurrDigits") & "<br>"
However, this returns me the iDigits and iCurrDigits values from
HKEY_USERS rather than HKEY_CURRENT_USER. Any idea why? I need the
values from HKEY_CURRENT_USER!!!
Cheers,
Benny
*** Sent via Developersdex http://www.developersdex.com ***
Try using HKCU instead of HKEY_CURRENT_USER
BC
2005-09-01 21:06:37 UTC
Permalink
Hi Jerold,

HKEY_CURRENT_USER and HKCU gives the same result. However I have found
out why.


Cheers,

Benny

*** Sent via Developersdex http://www.developersdex.com ***
d***@gmail.com
2015-10-29 18:29:37 UTC
Permalink
Post by BC
Hi Jerold,
HKEY_CURRENT_USER and HKCU gives the same result. However I have found
out why.
Cheers,
Benny
*** Sent via Developersdex http://www.developersdex.com ***
For VbScript et Asp page (use session. on asp) you can use the "locale" object :

Here is a VBS démo :

' Regional setting
WriteToFile logFile, "Regional Setting before : " & GetLocale()
SetLocale("fr-ca") 'SetLocale(0) ' system default
WriteToFile logFile, "Regional Setting after : " & GetLocale()

WriteToFile logFile, " (4105 = en-ca, 3084 = fr-ca, for other refer to http://www.devguru.com/technologies/vbscript/13928)"

Greetings.

Loading...