• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2297
  • Last Modified:

NEed to Change System Date Format Programmatically Using VB.NET

Hi,
I need to change the System Date Format programmatically to specific format. I should be able to get the current Date format then I should be able to change the System Date Format to dd-MMM-yy. Please help. Only vb.NET Code would be accepted.
0
payasiashish
Asked:
payasiashish
  • 3
  • 3
1 Solution
 
adomsgCommented:
txtDate.text =  Format(Date.Now,"dd-MMM-yy")
0
 
payasiashishAuthor Commented:
NO this is not what I Want.
I want to Access Regional Settings - Date and the specofy a Format to it, I do not want to format the date I want to get the Current Format of Date In the System and the Change the same (Date Format of the system) Programatically in VB.NET
0
 
Bob LearnedCommented:
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
payasiashishAuthor Commented:
With this I can retrive the date format however I am not able to set the date. It says its readonly property. Can you help me.
0
 
Bob LearnedCommented:
You can temporarily override this value:

Imports System.Globalization
Imports System.Threading.Thread
...

      Dim newCulture As CultureInfo = New CultureInfo(CultureInfo.CurrentCulture.Name)
      newCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yy"
      CurrentThread.CurrentCulture = newCulture
      MsgBox(CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern.ToString)
0
 
payasiashishAuthor Commented:
Thanks for the hellp but I am confused with Temporarily override thing. Can you elobrate this. Does this mean this will reset to what it was earlier after the program terminates?
0
 
Bob LearnedCommented:
I mean it doesn't stick after you close your program--not a permanent change.  I am thinking that this isn't a bad thing, just change it to what you want it to be within your program, and let the user keep what they already have.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now