TextBox Display

gladiator83x

Member
Joined
Jan 15, 2008
Messages
11
Programming Experience
Beginner
Hey All,

I am having a problem getting information to display automatically in the textboxes that I am using. I am specifically trying to having the current date shown. When I run my program, if one clicks inside the textbox, the date appears...however, I just wanted to ask if there was any way for the date to just appear in the textbox when I run my program, instead of having to click inside the textbox? Should I use something other than a textbox? Thanks.

Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
TextBox7.Text = DateAndTime.Now
End Sub
 
If you turn option strict on that code will throw an error because the now variable is of DateTime, and the Text property of the Textbox is of type string.

VB.NET:
TextBox7.Text = Now.ToShortDate
The above is an example of the many formats (as string) you can display the date and/or time in a Textbox
 
Back
Top