Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code that manipulates the appearance of a label in my user form.
The RGB is a shade of green, and the label's border and font colour are given this value. All appears normal.
I am trying to use the font colour in an evaluation, ie if the font is green (RGB 51, 204, 51) then ...
I am unable to the criteria of the if statement. I had previously assigned the forecolor to that RGB value, it hasn't changed, so I would expect the value of the forecolor to be RGB 51, 204, 51 as assigned.
In the immediates pane, if I type ?.Controls(hfg & "_en").ForeColor a value of 3394611 is returned. I'm not sure how to convert that to RBG, but I suspect my codes is failing because maybe 3394611 isn't the same as RGB 51,204,51?
Is anyone able to offer a solution?
Code:
With .Controls(hfg & "_en")
.BorderColor = RGB(51, 204, 51)
.BorderStyle = 1
.ForeColor = RGB(51, 204, 51)
End With
The RGB is a shade of green, and the label's border and font colour are given this value. All appears normal.
I am trying to use the font colour in an evaluation, ie if the font is green (RGB 51, 204, 51) then ...
Code:
With userfom1
If .Controls(hfg & "_en").ForeColor = RGB(51, 204, 51) Then
.Controls(hfg & "_en").ForeColor = RGB(0, 0, 0)
End if
I am unable to the criteria of the if statement. I had previously assigned the forecolor to that RGB value, it hasn't changed, so I would expect the value of the forecolor to be RGB 51, 204, 51 as assigned.
In the immediates pane, if I type ?.Controls(hfg & "_en").ForeColor a value of 3394611 is returned. I'm not sure how to convert that to RBG, but I suspect my codes is failing because maybe 3394611 isn't the same as RGB 51,204,51?
Is anyone able to offer a solution?