Date in Textbox


New member
Mar 17, 2005
Programming Experience
I am just moving to from vb6 and its all weird to say the least. My current problem is I have created a dataset which contains dates, When I bind and display the date to a textbox, I get '09/06/2005 00:00:00'. All I want to display is the date preferably in long date format.

How in the world do I put a format on the control or control what is displayed?

You can use the following code:

TextBox1.Text = FormatDateTime("1/1/05 12:33:10", DateFormat.LongDate)

I hope I helped you,
Hmm not really working.

The on_lostfocus code work if you tab away but if you click another textbox
control its runs the code but is reset back to the original format.
Hi again!

I think you are doing something wrong... Check all the other events in your code for that form.

If you want to write it to the lost_focus event, just write

TextBox1.Text = FormatDateTime(TextBox1.Text, DateFormat.LongDate)

if have put the following code in numerious places on a test form I just created including

If IsDate(txtDOB.Text) Then

txtDOB.Text = FormatDateTime(txtDOB.Text, DateFormat.LongDate)

End If

it works as long as I dont click another textbox in which case it reverts back to "12/10/2003 00:00:00"