you could try putting the common stuff in a method and return the
backcolor based on the string passed to it (the textbox text), or pass
the textbox control in to and set the backcolor inside it.
'text1 is a texbox
text1.backcolor = determinBackColor(text1.text)
public function determineBackColor(SomeText as String) as long
dim backcolor as long
backcolor= &cDBDBDB
If val(SomeText ) > 18 then
backcolor = &cFF8CC8
else
backcolor = &cF9FFCF
end if
return backcolor
end sub
Lennox Jacob wrote:
Hello,
How can I simplify this code?
I have a method: named ChangeColour and it goes like this:
If EF1.text = "" then
EF1.backcolor = &cDBDBDB
else
If val(EF1.text) > 18 then
EF1.backcolor = &cFF8CC8
else
EF1.backcolor = &cF9FFCF
end if
end if
If EF2.text = "" then
EF2.backcolor = &cDBDBDB
else
If val(EF2.text) > 18 then
EF2.backcolor = &cFF8CC8
else
EF2.backcolor = &cF9FFCF
end if
end if
If EF3.text = "" then
EF3.backcolor = &cDBDBDB
else
If val(EF3.text) > 18 then
EF3.backcolor = &cFF8CC8
else
EF3.backcolor = &cF9FFCF
end if
end if
If EF4.text = "" then
EF4.backcolor = &cDBDBDB
else
If val(EF4.text) > 18 then
EF4.backcolor = &cFF8CC8
else
EF4.backcolor = &cF9FFCF
end if
end if
If EF5.text = "" then
EF5.backcolor = &cDBDBDB
else
If val(EF5.text) > 18 then
EF5.backcolor = &cFF8CC8
else
EF5.backcolor = &cF9FFCF
end if
end if
If EF6.text = "" then
EF6.backcolor = &cDBDBDB
else
If val(EF6.text) > 18 then
EF6.backcolor = &cFF8CC8
else
EF6.backcolor = &cF9FFCF
end if
end if
If EF7.text = "" then
EF7.backcolor = &cDBDBDB
else
If val(EF7.text) > 18 then
EF7.backcolor = &cFF8CC8
else
EF7.backcolor = &cF9FFCF
end if
end if
If EF8.text = "" then
EF8.backcolor = &cDBDBDB
else
If val(EF8.text) > 18 then
EF8.backcolor = &cFF8CC8
else
EF8.backcolor = &cF9FFCF
end if
end if
If EF9.text = "" then
EF9.backcolor = &cDBDBDB
else
If val(EF9.text) > 18 then
EF9.backcolor = &cFF8CC8
else
EF9.backcolor = &cF9FFCF
end if
end if
If EF10.text = "" then
EF10.backcolor = &cDBDBDB
else
If val(EF10.text) > 18 then
EF10.backcolor = &cFF8CC8
else
EF10.backcolor = &cF9FFCF
end if
end if
If EF11.text = "" then
EF11.backcolor = &cDBDBDB
else
If val(EF11.text) > 18 then
EF11.backcolor = &cFF8CC8
else
EF11.backcolor = &cF9FFCF
end if
end if
If EF12.text = "" then
EF12.backcolor = &cDBDBDB
else
If val(EF12.text) > 18 then
EF12.backcolor = &cFF8CC8
else
EF12.backcolor = &cF9FFCF
end if
end if
If EF13.text = "" then
EF13.backcolor = &cDBDBDB
else
If val(EF13.text) > 18 then
EF13.backcolor = &cFF8CC8
else
EF13.backcolor = &cF9FFCF
end if
end if
If EF14.text = "" then
EF14.backcolor = &cDBDBDB
else
If val(EF14.text) > 18 then
EF14.backcolor = &cFF8CC8
else
EF14.backcolor = &cF9FFCF
end if
end if
If EF15.text = "" then
EF15.backcolor = &cDBDBDB
else
If val(EF15.text) > 18 then
EF15.backcolor = &cFF8CC8
else
EF15.backcolor = &cF9FFCF
end if
end if
Thanks.
Lennox
---------------------------------
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail Beta.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
-----------------
Utiba Pty Ltd
This message has been scanned for viruses and
dangerous content by Utiba mail server and is
believed to be clean.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>