Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

CLEARING ALL TXTBOXES ON A FORM IN ONE CALL

Untill now having a form with a lot off txtboxes on it , and user cancels input given,  I set all txtText.text  boxes  = "" 
Most off time not arrays , so loop is not usable, would there be a quick way to set all these txt-boxes to ""  in one
click
0
BIAPRO
Asked:
BIAPRO
  • 2
  • 2
1 Solution
 
bruintjeCommented:
Hello BIAPRO,

not sure what code you have but in vb you could do

Dim ctl As Control
   
  ' Clear all the TextBoxes on the form.
  For Each ctl In Controls
    If TypeOf ctl Is TextBox Then ctl.Text = ""
  Next ctl

source: http://www.vb-helper.com/howto_clear_textboxes.html

hope this helps a bit
bruintje
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
What are you programming in?  The above code is correct for VB and Access VBA (replace .Text with .Value for Access).
0
 
BIAPROAuthor Commented:
Ok bruintje  works for textboxes,  how to do for rich-textboxes???
0
 
bruintjeCommented:
think the same

Dim ctl As Control
   
  ' Clear all the TextBoxes on the form.
  For Each ctl In Controls
    If TypeOf ctl Is RichTextBox Then ctl.Text = ""
  Next ctl
0
 
BIAPROAuthor Commented:
Thanks, saves a lot off code
Regards Jack
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now