How to change Regional language setting date format to dd/MM/yyyy ?

Hi,

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

Any better ideas?

Thanks Again

Comments

  • seancampbellseancampbell Pennsylvania, USA
    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
  • seancampbellseancampbell Pennsylvania, USA
    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
  • 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_USERControl PanelInternational", "sShortDate", "dd/MM/yyyy")




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

    Thanks again.
  • seancampbellseancampbell Pennsylvania, USA
    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


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories