0
我想知道如何根据值更改值或文本框的颜色。例如,如果获得“F”,我希望此值在用户表单上以任何方式变为红色或文本框。Excel VBA更改USERFORM上的值的颜色
Here is a example of where i want to use it or how i would like to use it.
谢谢你的优势。
Private Sub cmdAceptar_click()
Dim n1 As Double, n2 As Double, n3 As Double, n4 As Double
Dim promedio As Integer
n1 = Val(txtn1): n2 = Val(txtn2)
n3 = Val(txtn3): n4 = Val(txtn4)
promedio = CInt((n1 + n2 + n3 + n4)/4)
txtPromedio = Str(promedio)
If promedio >= 90 And promedio <= 100 Then
txtPuntuacion = "A"
ElseIf promedio >= 80 And promedio <= 89 Then
txtPuntuacion = "B"
ElseIf promedio >= 70 And promedio <= 79 Then
txtPuntuacion = "C"
ElseIf promedio >= 60 And promedio <= 69 Then
txtPuntuacion = "D"
ElseIf promedio >= 0 And promedio <= 59 Then
txtPuntuacion = "F"
Else: MsgBox "Error de datos", vbCritical, "Mensaje"
End If
末次
THX帕特里克但这种解决方案是永久性的,我想情况下,如果得到一些值(如“F”)变成红色,但如果让其他的值(“B”)保持黑色 – Fulvio
我纯属点你改变文本框/文本颜色的方向。为“txtPuntuacion”添加另一个“If”块以在黑/红之间切换。 – PatricK
非常感谢您的帮助,完美的工作 – Fulvio