Clear the contents of a Form

aakbar

Member
Joined
Mar 7, 2007
Messages
6
Programming Experience
Beginner
Hi,
Is there a method which can clear all the contents of a Form.
contents means text in the text field or other controls.

Thanks
 
The easiest way to do this would be have an array of 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 ("").

CODE

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


Or, you could iterate through the form's controls collection and do the same thing, if you happen to use a predictable naming convention for textbox controls.


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

CODE

Text1.Text=""
Text2.Text=""
 
Back
Top