PDA

View Full Version : change font color for disable textbox



white_flag
09-03-2010, 05:33 AM
Hello

I like to know if this is possible: change font color for disable textbox. For the moment it is an gray font text + shadow (or at least to take the shadow out):

the code:


Private Sub Check()
Dim i As Integer

For i = 1 To 10
If Me.Controls("CheckBox" & i) = True Then
Me.Controls("TextBox" & i).Enabled = True
Me.Controls("TextBox" & i + 10).Enabled = True
Me.Controls("TextBox" & i + 20).Enabled = True
Me.Controls("TextBox" & i + 30).Enabled = True
Me.Controls("TextBox" & i).BackColor = &H80000005
Me.Controls("TextBox" & i).ForeColor = RGB(255, 0, 0)
Me.Controls("TextBox" & i + 10).BackColor = &H80000005
Me.Controls("TextBox" & i + 10).ForeColor = RGB(255, 0, 0)
Me.Controls("TextBox" & i + 20).BackColor = &H80000005
Me.Controls("TextBox" & i + 20).ForeColor = &H80000003
Me.Controls("TextBox" & i + 30).BackColor = &H80000005
Me.Controls("TextBox" & i + 30).ForeColor = &H80000003

Else
Me.Controls("TextBox" & i).Enabled = False
Me.Controls("TextBox" & i + 10).Enabled = False
Me.Controls("TextBox" & i + 20).Enabled = False
Me.Controls("TextBox" & i + 30).Enabled = False
Me.Controls("TextBox" & i).BackColor = &H80000003
Me.Controls("TextBox" & i).Font.ColorIndex
Me.Controls("TextBox" & i + 10).BackColor = RGB(255, 0, 0)
Me.Controls("TextBox" & i + 10).ForeColor = RGB(255, 0, 0)
Me.Controls("TextBox" & i + 20).BackColor = &H80000003
Me.Controls("TextBox" & i + 20).ForeColor = &H80000010
Me.Controls("TextBox" & i + 30).BackColor = &H80000003
Me.Controls("TextBox" & i + 20).ForeColor = &H80000010
End If
Next
End Sub

Me.Controls("TextBox" & i + 10).ForeColor = RGB(255, 0, 0) this is not working on disable ..on enable it is ok. so, What it is wrong?

Ken Puls
09-03-2010, 11:47 PM
It might help if you uploaded an example file so that we don't have to build one here....

white_flag
09-06-2010, 01:57 AM
please, look in attachment. thx

Ken Puls
09-07-2010, 10:35 PM
Hi there,

I'm not sure I quite follow what's not working here. I tried inserting the line of code you gave above, and it is working, although not in all cases. (Works on checkbox 1,2, but not some of the others.) Honestly, I haven't had time to look into it more deeply.

Can you be a little more clear on what isn't happening?

white_flag
09-08-2010, 07:32 AM
(check box) and the rest of the code is in sketch zone (so that one, it is not important) ..in what I am interested, it is just the color of the disable text.box. wen the text box is disable the color of the text it is ALLAYS gray with shadow (whatever I try to wright there in the code, the color remains the same (gray)) I like to put another color or to take out the shadow.

I am using Win Xp an excel 2003

Ken Puls
09-08-2010, 08:19 AM
Okay, that makes sense. I did have a fool around with it last night, and I see what you mean about the grey text. I can't see a text.color property at all for the textbox though. My suggestion would be to set up some more text boxes and hide them (either behind your current textboxes or off the side of the userform). Then in your disable code you can write the values to the secondary text boxes and clear out the first.

Not perfect, but hopefully should work...

white_flag
09-09-2010, 12:26 AM
ok, I will see (for the moment, I will let it like this), thx for your time.