TextBox Color Red if Less than 50

  • Thread starter Thread starter Shazi
  • Start date Start date
S

Shazi

Hi Everyone,

I have a textbox in userform, I want to change the TextColor (interior
color) if the value is less than 50 then it will be Blue. (to show the
quantity is less)

Regards.

Shahzad
 
Hi Everyone,

I have a textbox in userform, I want to change the TextColor (interior
color) if the value is less than 50 then it will be Blue. (to show the
quantity is less)

Regards.

Shahzad
Hello try this

Private Sub TextBox1_Change()
If TextBox1.Value < 50 Then TextBox1.BackColor = &HFF0000 Else
TextBox1.BackColor = &HFFFFFF

End Sub
 
This way maybe...

Private Sub TextBox1_Change()
If Val(TextBox1.Text) < 50 Then
TextBox1.BackColor = vbRed
Else
TextBox1.BackColor = vbWhite
End If
End Sub

Rick
 
Sorry, I couldn't tell if you were trying to change the font color or
the text box color. my previous post will change the text box color,
the code below will change the font color.

Private Sub TextBox1_Change()
If TextBox1.Value < 50 Then TextBox1.ForeColor = &HFF0000 Else
TextBox1.ForeColor = &HFFFFFF

End Sub
 
Back
Top