Link to home
Start Free TrialLog in
Avatar of DeclanFee
DeclanFee

asked on

Override regional settings in VB6

Need functions such as CDate etc to use Regional settings other than those in the current locale settings but I don't want to change the system settings.

i.e. Date seperator on the local pc is "." (Germany) but I want the VB code to use "/" (English) as the date seperator.

While other languages (VB.net, Delphi) will allow the locale settings to be overwritten within tha application I can't find any method to do this in VB6.

Note: While aware of how to read and change the system regional settings within VB6 I only want to change them for this specific applications, I don't want to affect other applications running on this PC.  

Thanks
Avatar of pradapkumar
pradapkumar

you can simply use the following line to get english date

strEngDate = Format(Date, "dd/mm/yyyy")

To get Time as you wish

strCurTime = Format(Time,"hh:mm:ss")

thats all.
It won't affect the system settings and other applications.
Avatar of DeclanFee

ASKER

pradapkumar, Thanks for the comment, unfortunately my problem is a bit more complex than this. I have the source code for a large 3rd party app that I need to run on both german and English locale PCs. The app passes data in XML format to components on a shared server (English locale). The local client PC also read default values from config files which have all values in English locale date and numeric format such as "9,999,999.99" as opposed to German format "9.999.999,99"   -  I want to avoid significant redevelopment work. I'm happy to force users on both locales to enter data in English format ( "." as decimal seperator,  "," as thousand seperator etc.) but I need to force the locale aware functions in VB to use "," as the thousand seperator, "." as the decimal seperator and "/" as the date seperator despite the system locale settings being different.

Perhaps this isn't possible in VB6 in which case I'd have to persue other options.

Cheers
Avatar of Dana Seaman
You can do this in your app using following code. It relies heavily on API and you can use any supported Locale(LCID) you want:
http://www.cyberactivex.com/download/InternationalLocales.zip

The formatting code is in class Locale.cls where you set the Locale(LCID) and then format your numbers, dates, etc. using a user specified LCID independent of the Regional Settings.

If you need help with any of this let me know.
ASKER CERTIFIED SOLUTION
Avatar of Dana Seaman
Dana Seaman
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Danaseaman, thanks for your post, looks like exactly what I need to resolve my problem. Will review code fully and get back to you later today. Thanks