VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to change Regional language setting date format to dd/MM/yyyy ? Posted by MAHEY on 12 May 2009 at 3:22 AM
Hi,

Iam looking to change programmatically, from Regional language setting [control pannel] date format to dd/MM/yyyy .

Any better ideas?

Thanks Again
Report
Re: change Regional language setting date format to dd/MM/yyyy ? Posted by seancampbell on 12 May 2009 at 5:48 AM
I found a Forum post that said to use the SetLocaleInfo API from Windows, and that you could do this through that. That same Forum thread had a post that suggested just changing how you format the data in the program rather than changing the Local user settings, because having software that randomly changes your local user settings is Mega annoying, and considered bad programming...

After some more searching, I found this article. It was written for VB5 or VB6, but the code should work in VB.Net (I am not able to change the setting due to admin rights, so I never tested that it works)

http://vbnet.mvps.org/index.html?code/locale/setlocaleinfo.htm

The part where it does a "Public Declare Function EnumDateFormats Lib "kernel32"" is you adding a reference to a specific command in a DLL, in this case the EnumDateFormats in Kernel32.dll

Have fun,
Campbell
firesickle.com
Report
Re: change Regional language setting date format to dd/MM/yyyy ? Posted by seancampbell on 12 May 2009 at 5:57 AM
Mahey, you seem to be a pretty capable programmer, but I just want to add a note on what I posted to help you out:

The top section of code is meant to go in a Module code file, the VB6 extension was BAS, that is why it calls it a BAS module (in .Net the extension is .VB)

The second part is code that goes onto your Form (which there is a screen shot at the top right). In VB6, there wasn't such a thing as "Handlers" so code behind was handled with something behind the scenes which added function handlers from Routines to Objects at runtime. (well that is the best I understand it, I was in grade school when .Net first came out, so my experience with it is limitted).

You will have to "link" the routines to each object on the form yourself, because simply copy and pasting won't be enough. You can create the form, double click the object you want to add code to, and paste in the code from the proper area. (You'll probably be able to tell what goes where based on the Routine names)

In VB6, Buttons were called Command1, Command2

If you need any help let me know, I have converted many programs from VB6 to .Net
Report
Re: change Regional language setting date format to dd/MM/yyyy ? Posted by MAHEY on 12 May 2009 at 10:25 PM
Thank You SEAN !

I received from another experts [as like you], also stating the same ideas, don't do it from control pannel and can be do it from Form.


Imports System.Threading
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB", False)

[or] For regional language setting

Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", "dd/MM/yyyy")




this will set date to dd/MM/yyyy format to that form. So my requirement is solved.

Thanks again.
Report
Re: change Regional language setting date format to dd/MM/yyyy ? Posted by seancampbell on 13 May 2009 at 5:14 AM
No Problem

I would hardly call myself an expert, I'm more of an average programmer who has Internet Search Engine Skills :)

Glad to hear you figured something out,
Sean Campbell





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.