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

Change Texbox Colors Based on Severity of Change

Status
Not open for further replies.

RacingSoftwareGuy

Programmer
Jul 19, 2005
9
US
I would like to change the text box backcolor depending on the severity of changes in their values.

I currently have the backcolor change to red if the value is positive and light blue if the value is negative. These are visual clues to the operator that something is happening.

I would like to change the color slightly as the value nears no change and more radically if the value begins to get out of the normal range.

For example, if the change is 10 I want bright red, however if the change is only 5 I want a much less intrusive red. Is there a way to calculate with math the next red or blue color that should be used rather than a Do Case type of procedure?



Don Higgins
 
The human eye has a non-linear response to colour so you'll do better setting the exact shades with a CASE statement. If you want to try the maths then set Red to 255 and ramp up the Green and Blue components of BackColor to fade it in to pink:

[TT]BackColor=RGB(255, 255 - (25*Change), 255 - (25*Change))[TT]

will give you white for a zero change and bright red for a change of 10.

Geoff Franklin
 
Don - You should be very careful about hard-coding colors into an application. Generally, it's better to rely on the colors the user has chosen in Windows and work with variants of those. Hard-coding colors can make things unreadable for people with color blindness.

Tamar
 
Thanks to all.

Tamar, I have made the colors user selectable for the most part. They can pick the base color or even disable the color changing routine with a mouse click.

It seems to work well, and in this business of split second decision making the colors add an important visual clue to the severity of changes in certain weather factors that drastically effect engine power and clutch engagement controllers.



Don Higgins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top