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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referring to Value of Text Box

Status
Not open for further replies.

fredk

Technical User
Jul 26, 2001
708
US
I have about 25 text boxes that hold values - both positive and negative - If I want to have each of the 25 reviewed and the text color changed to red or black depending on the value, I thought I could use a for next statement to run through all the controls - My question is how do I refer to the value of the variable in my code.

In other words, if I only needed to look at one value I would use If [text1] < 0 - When I am using a variable how do I refer to the value of the variable?

Thanks for the assistance!!!
 
Hi,

You could use:

Dim Ctl As Control

For Each Ctl In Me.Controls
If TypeOf Ctl Is TextBox Then
Ctl.ForeColor = IIf(Ctl < 0, vbRed, vbBlack)
End If
Next Ctl
Set Ctl = Nothing

Have a good one!
BK
 
Thanks for your help BK - I really appreciate it!!!!!

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top