TextBox Color Red if Less than 50

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
 
G

GTVT06

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
 
R

Rick Rothstein \(MVP - VB\)

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
 
G

GTVT06

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top