Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Interface and Graphics

Post new topic   Reply to topic
How to 'Reload' a form?
View previous topic :: View next topic  
Author Message
Mitesh2004
Freshman


Joined: 26 Jan 2004
Posts: 43

PostPosted: Jan 27th, 2004 08:47 AM    Post subject: How to 'Reload' a form? Reply with quote

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
View user's profile Send private message Send e-mail
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Jan 27th, 2004 09:36 AM    Post subject: Reply with quote

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
View user's profile Send private message
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Jan 27th, 2004 04:48 PM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
Mitesh2004
Freshman


Joined: 26 Jan 2004
Posts: 43

PostPosted: Jan 28th, 2004 09:39 AM    Post subject: Reply with quote

Thanks guys! Thats great!!! =D
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Interface and Graphics All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic