Text box format VBA
"gregork" wrote in message
...
I want to format back colour based on text in a textbox. i.e. If
textbox27 text="fail" then
TextBox27.BackColor = &HC0C0FF.
You are very close:
If TextBox27.Text = "fail" Then
TextBox27.BackColor = "&HC0C0FF"
Else
TextBox27.BackColor = "&HFFFFFF"
End If
But consider uppercase, mixed case, part entries, trailing spaces...
If InStr(Trim$(LCase$(TextBox27.Text)), "fail") 0 Then
reacts also on entry " You FAILED madam"
--
HTH. Best wishes Harald
Followup to newsgroup only please.
|