Solved

Controling all text boxes

Posted on 2001-08-14
12
157 Views
Last Modified: 2010-05-02
I am looking for that loop where I can set the properties of all the controls without listing them for example

For each control in frmMain
   if control.type = textbox then
      control.caption = ""
   end if
Next
0
Comment
Question by:dhamijap
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6385348
i guess this is better:

For each control in frmMain
  if TypeName(control) = "Textbox" then
     control.text = ""
  end if
Next

Cheers
0
 
LVL 3

Accepted Solution

by:
Diveblue earned 20 total points
ID: 6385350
Youve almost got it..

Dim thisControl As Control
For Each thisControl In Me.Controls
  If TypeOf thisControl Is TextBox Then
     thisControl.Text = ""
  End If
Next

hope it helps



0
 
LVL 3

Expert Comment

by:Diveblue
ID: 6385355
angel's version is good too
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:hes
ID: 6385364
If you Name all your Textboxes like TxtWhatever then you can use

For Each Control In Form1
If Control.Name Like "Txt*" Then
   Control.Text = "hi"
End If
Next
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6385383
<---- Code Begin ---->

   Dim objControl As Control
   For Each objControl In Me.Controls
      If TypeOf objControl Is TextBox Then
         objControl.Text = "This Is A Test"
      End If
   Next objControl

<---- Code End ---->

0
 

Author Comment

by:dhamijap
ID: 6385391
angelIII
I tried yours it did not work. it went through the loop though.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6385394
ooops, too late :-)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6385404
sorry, it's an uppercase B in the "Textbox" ...

For each control in frmMain
 if TypeName(control) = "TextBox" then
    control.text = ""
 end if
Next

0
 

Author Comment

by:dhamijap
ID: 6385428
Diveblue you code worked perfect. Just as i wanted.
I am accepting your answer. Sorry hes and wsh2 the first acceptable answer gets the points. Yours looks like it is going to work. Thanks for your response.
0
 

Author Comment

by:dhamijap
ID: 6385436
Very good. Thanks a lot.
0
 
LVL 20

Expert Comment

by:hes
ID: 6385471
dhamijap,
No need to be sorry, we work as a team here. Glad you got yor solution so quick.
0
 

Author Comment

by:dhamijap
ID: 6385514
Like your thoughts. Thanks a lot
dhamijap
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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