6 Replies - 56133 Views - Last Post: 06 August 2010 - 11:30 AM Rate Topic: -----

#1 sneddog  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 17-November 05

VB.NET - Reset Form Fields

Posted 17 November 2005 - 03:09 AM

Hello,

I am a complete novice when it comes to programming. I am working a project that I have nearly completed, but I need a little help. I have a reset button created in my VB form, but don't know how to code it so that it will accomplish what I want. I want it to clear the form's text boxes so that new input can be entered. I could just code an end statement but this closes the form, and I want to keep it open to continue working with it. Any help would be greatly appreciated.

Thanks,
sneddog

Is This A Good Question/Topic? 1
  • +

Replies To: VB.NET - Reset Form Fields

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: VB.NET - Reset Form Fields

Posted 17 November 2005 - 06:19 AM

The easiest way to do this would be have an array fo all text box names on your form. In the procedure for your reset button, loop through the array, and set all the text box values to empty ("").
Dim i as Integer
Dim tboxes(4) as String = New String() {"Text1","Text2","Text3","Text4"}
For i = 0 To 3
   'set the value to ""
Next i



You could also do it sequentially...when the button is clcked, just have several lines of code to clear the boxes
Text1.Text=""
Text2.Text=""


Was This Post Helpful? 0
  • +
  • -

#3 sneddog  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 17-November 05

Re: VB.NET - Reset Form Fields

Posted 20 November 2005 - 11:51 PM

Thanks Amadeus for your advice, worked flawlessly.

sneddog

This post has been edited by sneddog: 20 November 2005 - 11:52 PM

Was This Post Helpful? 0
  • +
  • -

#4 Jozahra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-March 09

Re: VB.NET - Reset Form Fields

Posted 08 March 2009 - 07:57 AM

I have created a reset button which allows me to reset all contents of the fields but u dont know the code can someone help me pls ?
Was This Post Helpful? 0
  • +
  • -

#5 Cebe  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 13-April 09

Re: VB.NET - Reset Form Fields

Posted 13 April 2009 - 08:23 AM

Hi,

This seemed a suitable topic to reply to rather than starting a brand new one.

I was looking to do the same thing; clearing all the text from boxes which I have achieved fine.

My problem is that when I press "F2" to clear all the boxes (which works fine), I also want to reset the tab position back to the very start of the form, having the text curser flashing in the first textbox such that the form can be filled out again instantly. Is there a way to achieve this with VB.NET?

Thanks in advance.
Was This Post Helpful? 1

#6 Guest_Guest*


Reputation:

Re: VB.NET - Reset Form Fields

Posted 06 August 2010 - 11:28 AM

In order to set the tabs to original position you would do something like:

tabcontrol1.selectedindex = -1


So if you had multiple tabs and you wanted to return to the first one just do a:

tabcontrol1.selectedindex = 0


The default index of any tab control (unless otherwise specified) is -1, which refers to nothing being selected.

To go have the cursor flashing in the textbox at the beginning just do something like:

myTextbox.focus()


This will put the blinking cursor in whatever textbox you choose, in your case the first one in the tab.

Hope this helps :bigsmile:

-Crash
Was This Post Helpful? 0

#7 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10467
  • View blog
  • Posts: 38,797
  • Joined: 27-December 08

Re: VB.NET - Reset Form Fields

Posted 06 August 2010 - 11:30 AM

Crash, I appreciate your willingness to help. However, as this thread is almost 5 years old, I don't think the OP is checking back anymore. Please avoid necroposting in the future. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1