• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

Using "clear" button to set focus to text box

I have a button called called btnclear
I want to make it so that when i click it it clears all the text fields and sets the focus to my text box called tstFirstName.Text

Thanks for the help i am new as you can see in the code below i am using the easiest way i know how to clear them
txtFirstName.Text = ""
txtLastName.Text = ""
lblNameOutput.Text = ""
txtFirstNum.Text = ""
txtSecondNum.Text = ""
lblNumOutput.Text = ""

Open in new window

0
aspirinmornings
Asked:
aspirinmornings
  • 2
  • 2
1 Solution
 
Ashish PatelCommented:
right, you code is good and has no issues, now on the btnclear click just write your code and the end write txtFirstName.setFocus()

txtFirstName.Text = ""
txtLastName.Text = ""
lblNameOutput.Text = ""
txtFirstNum.Text = ""
txtSecondNum.Text = ""
lblNumOutput.Text = ""
txtFirstName.setFocus()
0
 
aspirinmorningsAuthor Commented:
when i do that it comes up with a #3 error
it says 'setFocus' is not a member of "system.Windows.Forms.TextBox'.
0
 
Ashish PatelCommented:
oh you are using vb.net then use  below line at the end.

txtFirstName.Focus()

0
 
aspirinmorningsAuthor Commented:
THANKS!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now