Not sure exactly what is wrong here. I'm not sure if I am supposed to be using "else if" or what. Here's the code:
private void txtMessage_TextChanged(object sender, EventArgs e)
{
int length = txtMessage.TextLength;
int left = 140 - length;
charactersleft.Text = left.ToString() + " characters left";
if (left < 140)
{
charactersleft.ForeColor = Color.Green;
}
if (left < 110)
{
charactersleft.ForeColor = Color.Yellow;
}
if (left < 80)
{
charactersleft.ForeColor = Color.Orange;
}
if (left < 50)
{
charactersleft.ForeColor = Color.Red;
}
else
{
charactersleft.ForeColor = Color.Black;
}
}
The forecolor of the label "charactersleft" is supposed to change depending on the number of characters within txtMessage. But for some reason it's not working. I'm sure the solution is simple, I'm just easily confused with the whole "else if" thing. Thanks in advance.