VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A simple Clear All Controls on FormJust 4 Lines

by Cor! (1 Submission)
Category: Libraries
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (30 Votes)

Need to perform the same action on multiple controls in your form? Then this simple code might just be for you..
This particular example will show you the most efficient way to clear every text box on a form.
This method can be especially useful if you're adding and removing controls during the development of a project.

Rate A simple Clear All Controls on FormJust 4 Lines



I guessed there must be a better way than hard-coding each control name, but I searched PSC and couldn't find anything to do the job. So after I worked it out I felt this simple method should be added to PSC so those who don't already know how to do it can benefit too.




Dim Control As Control

For Each Control In Me

 If TypeOf Control Is TextBox Then Control.Text = ""

Next Control



Please vote if you learnt something useful.

Cor!™

Download this snippet    Add to My Saved Code

A simple Clear All Controls on FormJust 4 Lines Comments

No comments have been posted about A simple Clear All Controls on FormJust 4 Lines. Why not be the first to post a comment about A simple Clear All Controls on FormJust 4 Lines.

Post your comment

Subject:
Message:
0/1000 characters