[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Clearing Textboxes on form GroupBox

Posted on 2004-11-25
4
Medium Priority
?
448 Views
Last Modified: 2010-04-23

Hi,
I have 10 texboxes placed in  a groupBox on a windowsform. I would like to clearall the texboxes  .
Is there a way to specify which textboxes in the 10 present  I dont want to clear looping thru the textboxes on the form
like if txtname then avoid clearing it
Thx in advance
0
Comment
Question by:sainavya1215
  • 2
  • 2
4 Comments
 
LVL 14

Expert Comment

by:ptakja
ID: 12677198
You can put the textboxes into an array & then check the names to determine if you want to clear them or not:

Dim atxtboxes as TextBox() = {Textbox1, Textbox2, Textbox3, TextBox4, TextBox5, TextBox6, Textbox7, Textbox8, Textbox9, Textbox10}

Dim ii As Integer
For ii = 0 to atxtboxes.Length-1
     Select Case atxtboxes(ii).Name
          Case "TextBox1", "TextBox3"       'Clear all textboxes in array EXCEPT Textbox1 & Textbox3
          Case Else
               atxtboxes(ii).Text = String.Empty
      End Select
Next
0
 

Author Comment

by:sainavya1215
ID: 12682876
Dim atxtboxes as TextBox() = {Textbox1, Textbox2, Textbox3, TextBox4, TextBox5, TextBox6, Textbox7, Textbox8, Textbox9, Textbox10}

Is this an array..... ?? Instead of mentioning all the textboxes in array cant we do it by looping thru textbox controls on form
0
 

Author Comment

by:sainavya1215
ID: 12682970
MoreOver these textboxes as mentioned are placed in Groupbox
0
 
LVL 14

Accepted Solution

by:
ptakja earned 1000 total points
ID: 12690546
Sure you can. Here's what that code would look like:


For Each ctl As Control In GroupBox1.Controls
    If TypeOf(ctl) Is TextBox Then
        ctl.Text = String.Empty
    End If
Next
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question