How do I code to clear textbox when clicked?

bigboywasim

Member
Joined
Sep 29, 2006
Messages
18
Programming Experience
Beginner
How do I code to clear textbox when clicked? This will be under the private sub of the textbox right?
 
To clear the textbox when clicked, you need a new sub that will be called when you click the textbox. To get this sub, look at the top of the form's code page, and you'll see two drop down boxes. In the one on the left, click the name of the text box. In the one on the right, click "Click". This will create a sub for you like the one below. The only line you need is TextBox.Text = ""

VB.NET:
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
     TextBox1.Text = ""
End Sub

Hope this helps.
 
true, the clear thing works to. however it does not work for labels, so it is good practice to use the textbox.text = "" instead, as it works for both.
 
Back
Top