Solved

NEed to Change System Date Format Programmatically Using VB.NET

Posted on 2003-12-10
7
2,259 Views
Last Modified: 2008-05-28
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
Comment
Question by:payasiashish
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:adomsg
ID: 9918538
txtDate.text =  Format(Date.Now,"dd-MMM-yy")
0
 

Author Comment

by:payasiashish
ID: 9918596
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9920047
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:payasiashish
ID: 9920406
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9920784
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
 

Author Comment

by:payasiashish
ID: 9925929
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
 
LVL 96

Accepted Solution

by:
Bob Learned earned 75 total points
ID: 9927866
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to ToolkitScriptManager 2 30
crm development 2 37
DataGridview Currency Formating? 22 38
Check if number is currency 15 29
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now