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!

Can't conditionally change forecolor of textbox

Status
Not open for further replies.

smeyer52

Technical User
Mar 11, 2001
9
US
if textbox.forecolor = system.drawing.color.green then
textbox.forecolor = system.drawing.color.red

will not compile.
VB.net gives me the message that "operator '=' is not defined for types 'system.drawing.color' and 'system.drawing.color'." with error highlight on the
"if ... then" line, not with the second line. I do not understand the problem nor know a solution. Any help? I need to conditionally change the forecolor. Thanks.
 
system.drawing.color is of a type STRUCTURE, so you need to use .EQUALS:

if textbox.forecolor.equals(system.drawing.color.green) then
textbox.forecolor = system.drawing.color.red

This should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top