Date in Textbox

99pshop

New member
Joined
Mar 17, 2005
Messages
3
Programming Experience
3-5
I am just moving to vb.net 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?
 

etatis

New member
Joined
Mar 17, 2005
Messages
3
Programming Experience
3-5
HI!

You can use the following code:

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

I hope I helped you,
Jimmie
 

99pshop

New member
Joined
Mar 17, 2005
Messages
3
Programming Experience
3-5
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.
 

etatis

New member
Joined
Mar 17, 2005
Messages
3
Programming Experience
3-5
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)

Bye.
 

99pshop

New member
Joined
Mar 17, 2005
Messages
3
Programming Experience
3-5
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"
 
Top Bottom