Hi.
I'm trying to make a userform textbox to change color depending on the input value.
I managed to get one of my textboxes to display the correct color based of the value, but then i got a second texbox, that is going to change the color based on a calculation from the first textbox, and the input that is put in the textbox 2, then it shows the color at wrong values.
This is what i got:
Private Sub syl_20_tip1_rk1_Change()
On Error Resume Next
Select Case syl_20_tip1_rk1.Value
Case 11.185 - 0.02 To 11.185 + 0.02:
syl_20_tip1_rk1.BackColor = vbGreen
Case 11.155 To 11.165:
syl_20_tip1_rk1.BackColor = vbYellow
Case 11.205 To 11.215:
syl_20_tip1_rk1.BackColor = vbYellow
Case 11.155 - 11.155 To 11.215 + 20:
syl_20_tip1_rk1.BackColor = vbRed
Case Else:
syl_20_tip1_rk1.BackColor = vbWhite
End Select
End Sub
Private Sub syl_20_tip1_rk2_Change()
On Error Resume Next
Select Case syl_20_tip1_rk2.Value
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text + 0.01:
syl_20_tip1_rk2.BackColor = vbGreen
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text - 0.01:
syl_20_tip1_rk2.BackColor = vbGreen
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text - 0.02:
syl_20_tip1_rk2.BackColor = vbYellow
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text + 0.02:
syl_20_tip1_rk2.BackColor = vbGreen
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text + 0.03:
syl_20_tip1_rk2.BackColor = vbRed
Case Else:
syl_20_tip1_rk2.BackColor = vbWhite
End Select
End Sub
The first one, works just fine, but when i try to (in textbox2(which is not called textbox 1 and 2, just easier to write so you understand )) set a value in textbox 2, the calculations are off.
How can i improve on this one?
Also tried .value instead of .text, but no changes.
I'm trying to make a userform textbox to change color depending on the input value.
I managed to get one of my textboxes to display the correct color based of the value, but then i got a second texbox, that is going to change the color based on a calculation from the first textbox, and the input that is put in the textbox 2, then it shows the color at wrong values.
This is what i got:
Private Sub syl_20_tip1_rk1_Change()
On Error Resume Next
Select Case syl_20_tip1_rk1.Value
Case 11.185 - 0.02 To 11.185 + 0.02:
syl_20_tip1_rk1.BackColor = vbGreen
Case 11.155 To 11.165:
syl_20_tip1_rk1.BackColor = vbYellow
Case 11.205 To 11.215:
syl_20_tip1_rk1.BackColor = vbYellow
Case 11.155 - 11.155 To 11.215 + 20:
syl_20_tip1_rk1.BackColor = vbRed
Case Else:
syl_20_tip1_rk1.BackColor = vbWhite
End Select
End Sub
Private Sub syl_20_tip1_rk2_Change()
On Error Resume Next
Select Case syl_20_tip1_rk2.Value
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text + 0.01:
syl_20_tip1_rk2.BackColor = vbGreen
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text - 0.01:
syl_20_tip1_rk2.BackColor = vbGreen
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text - 0.02:
syl_20_tip1_rk2.BackColor = vbYellow
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text + 0.02:
syl_20_tip1_rk2.BackColor = vbGreen
Case syl_20_tip1_rk1.Text - 0.041 To syl_20_tip1_rk1.Text + 0.03:
syl_20_tip1_rk2.BackColor = vbRed
Case Else:
syl_20_tip1_rk2.BackColor = vbWhite
End Select
End Sub
The first one, works just fine, but when i try to (in textbox2(which is not called textbox 1 and 2, just easier to write so you understand )) set a value in textbox 2, the calculations are off.
How can i improve on this one?
Also tried .value instead of .text, but no changes.