Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locale confusion 1

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
I have a VB application that needs to format dates & currencies according to locale. In order to determine the locale, I have been using the API call GetSystemDefaultLCID and passing the result in other locale related API calls to establish currency symbol, date format etc.

This all seemed to be working fine (Windows XP) until I started testing on a different (Windows 2000) box when, despite all control panel settings being UK related, the date format being returned was US and not consistent with the control panel (regional options). By changing the call to GetUserDefaultLCID, it now seems fine.

I accept that the difference in operating system may be immaterial and it could just be due to different settings on the respective boxes but can anyone explain the difference between User and System in this context and how are they both updated outside code (e.g. in control panel).

Thanks in advance.
 
The GetSystemDefaultLCID is the local that the OS was installed on, or what the user has changed to via the control panel (the country). (As you probably have seen before, this always requires a reboot and is used to determine which code pages are used by the system.
The system local determines what code page to use, among other things.
The GetUserDefaultLCID is the local information for Date, time, Number and Currency formats only, which can be changed by the user in the control panel region settings for the currently selected country/language.

If these settings are left the same as the system default, then both of the API functions should return the same LCID.

Always use the GetUserDefaultLCID in order to determine those mentioned formats.
 

>Hmmm - this may get me somewhere:

Yep. That's what it's about.
 
Thanks CCLINT - it is certainly becoming clearer though not 100% sure why it seemed to be behaving under XP. Agreed, however that my original approach was wrong and I should be using user locale.

Silly question perhaps but how do you change the country (system locale) in Control Panel (Win2k)? Is it in Regional Options? I only see a reference to 'your locale (location)' in a frame with caption 'settings for current user'. I assume this is the User locale?
 

I don't know what it's called in english off hand, but you will notice at the bottom of the dialog a button to Change the System Local.

This is where the reboot will occure in order to change the code page.
This is the setting for the GetSystemDefaultLCID

 

>a button to Change the System Local

Something like "Set Standard" ?

As said, this changes the code page actually used, along with possibly fonts, etc.

Change the Country for the user with-out changing the standard, just affects the formating and keyboard, but not the code page.
 
OK, I'm with you - it's actually 'Set Default'.

That's cleared that one up, thanks. Have a star.
 
Hi Glasgow,

To save me reinventing the wheel, is there any code you can post to help me format a number in the local currency?

Thanks,

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Hi Andy

I'm really sorry but I'm snowed under at the moment and would need to search through a chunk of code to determine the different steps I took. However, if no-one else responds, please feel free to re-activate the post in about a week and I'll try and look out the solution(s).

In the meantime, have you tried checking out the FormatCurrency function. It could just be that simple!
 
Um....don't FormatDateTime and FormatCurrency sort this all out for you? Or am I missing something?
 
Hi Strongm & Glasgow -

Yeah - that's perfect! I never knew those commands existed! If it wasn't in VB1.0 I probably missed its addition...


- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top