| View previous topic :: View next topic |
| Author |
Message |
Mitesh2004 Freshman
Joined: 26 Jan 2004 Posts: 43
|
Posted: Jan 27th, 2004 08:47 AM Post subject: How to 'Reload' a form? |
|
|
Hello,
I am new to VB and am in desperate need of some help.
How do i make all the inputs that are typed into a form disappear? is there a command that will do this?
For example, if there are many text boxes on a form and various information has been entered into it. Is there a command that i could use that would reset the form at the click of a button?
I would be very grateful for any help.
Cheers!! |
|
| Back to top |
|
Andir Centurion

Joined: 21 Dec 2003 Posts: 184 Location: Chicago Area
|
Posted: Jan 27th, 2004 09:36 AM Post subject: |
|
|
you could always run this bit of code in your button_click routine:
| Code: |
On Error Resume Next
For Each Control In Me
Control.Text = ""
Next Control
|
The 'On Error Resume Next' Is very important for this, if you have labels or lists on the form, it will error out without this. Be warned though, this method will clear any control with the .text property. _________________ If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too. |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jan 27th, 2004 04:48 PM Post subject: |
|
|
That is correct but I usually prefer to avoid error trapping if possible(especially OERN)... I usually do it like this :
| Code: | Private Sub Command1_Click()
Dim Ctl As Control
For Each Ctl In Me.Controls
If TypeOf Ctl Is TextBox Then
Ctl.Text = ""
End If
Next
End Sub |
_________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
Mitesh2004 Freshman
Joined: 26 Jan 2004 Posts: 43
|
Posted: Jan 28th, 2004 09:39 AM Post subject: |
|
|
| Thanks guys! Thats great!!! =D |
|
| Back to top |
|
|