Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Background Color of Text Boxes on a Form 1

Status
Not open for further replies.

campbere

Technical User
Oct 10, 2000
146
US
Hello,

I have a subprocedure that changes the background for all text objects on a form. Currently I have it set up like this:

public sub chngcolor()

with form1

.txtbox1.backcolor = thewhitecolor
.txtbox2.backcolor = the whitecolor
etc...
end with

What I would like to do is make this more general.

I would like to make a function that you pass the forms name in and for every text oject on the form the function changes the background color. The trouble I am having is finding information on how I reference every text object on the form without specifically listing the name. I believe this is object oriented programing that I am attempting.

Can someone help?
 
Could you please specify what version of Seagate Crystal Forms you use? :)
 
You may want to put this in the vb forum (if vb is what you are using)

If in fact you ARE using vb:
To reference every object on a form

public sub chngcolor(formname as form)

For Each cntl In formname.Controls
If TypeOf cntl Is TextBox Then
cntl.backcolor = thewhitecolor
end if
next cntl

Transcend
[grogeous]
 
oh i forgot the

Dim cntl as Control just before the for loop

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top