473,387 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Short date to long date

After the user enter in short date in text box, once the user tabs out of the
text box I want the short date to change automatically to long date. What is
the code to make this change and what is the best event to put it in?
Nov 17 '05 #1
2 2198
There are 3 parts to accomplishing this, all quite easy.

First up, you’ll want to subscribe to the TextBox’s Leave event.

Next, you would need to read the value from the TextBox and convert it into
a DateTime class, easiest way to do that is with the static Parse() method
that is part of the DateTime class.

Finally, output the LongDate format by calling the ToLongDateString() method
on the instance you just created.

All in all, the majority of your code would look not unlike:

private void myTextBox_Leave(object sender, System.EventArgs e)
{
DateTime enteredDate = DateTime.Parse(myTextBox.Text);
textBox1.Text = enteredDate.ToLongDateString();
}

One note, it would be wise to do some sort of checking prior to the Parse(),
or at least wrap it in a try/catch block just incase the user puts in an
invalid date that it chokes on.

Brendan
"Mike L" wrote:
After the user enter in short date in text box, once the user tabs out of the
text box I want the short date to change automatically to long date. What is
the code to make this change and what is the best event to put it in?

Nov 17 '05 #2
Hi Cadel,

Does Brendan's reply make sense to you? Is your problem resolved? Please
feel free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
0
by: Ethel Aardvark | last post by:
I am running a 9.0.1 database on a W2K server and have come across some strange behaviour with a SQL query. I have a query which runs in a PL/SQL cursor which has several PL/SQL variables used to...
4
by: Jo | last post by:
Is there anyway we can know using JavaScript the Short Date Format used in the Control Panel -> Regional and Language Settings? I know the using the combinations of following we can get the...
34
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1...
2
by: ABC | last post by:
Hi, All Which function return the desktop long and short date formats? Thanks
40
by: Spiros Bousbouras | last post by:
Do you have an example of an implementation where sizeof(short int) does not divide sizeof(int) or sizeof(int) does not divide sizeof(long int) or sizeof(long int) does not divide sizeof(long long...
0
by: Curious | last post by:
Hi, I have two columns defined as DateTime type in the Visual Designer, i.e., Dataset.xsd. In the grid to which the columns are bound, they're both displayed as date, for instance, 5/23/2007....
1
by: Doug | last post by:
Hi, I created a short date field. The format is dd/mm/yyyy when displayed. The input mask is set to 99/99/00;0 (default, I didn't type anything). If I edit an existing date, say change...
5
OuTCasT
by: OuTCasT | last post by:
Hi. I would like to know how to convert the short date format to the long date format for my application without changing the regional settings from short date to long date. ?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.