
Changing the Background (color) property for all Textbox controls
If you were using a control array (of textboxes), you could do "something"
like the following:
Private Sub txtText_GotFocus(Index As Integer)
Call SetTextBackColor
End Sub
Private Sub txtText_LostFocus(Index As Integer)
Call SetTextBackColor
End Sub
Sub SetTextBackColor( )
Dim vText As Variant
For Each vText In Textboxes
vText.BackColor = IIf(vText.Index = ActiveControl.Index, vbYellow,
vbWhite)
Next vText
End Sub
I haven't run this example through the wringer, so I won't guarantee
results; but it seems like it will work. WYSIWYG.
--
Hope this helps...
Jeffrey Renton
jrenton AT ees DOT enron DOT com
Quote:
> I have a form with many normal Textbox controls.
> Actually, it's so many that sometimes it's hard to
> know where the insertion point is. I want to change
> the color of the textbox with focus. Every time I
> press the TAB key or click on another textbox, the
> background color of the preceding textbox should
> change to white as before, and the focused textbox
> should turn to, for example, light yellow. It would
> be nice to make it globally, not in the GotFocus()
> and LostFocus() event of every control.
> Best Regards
> Gustaf Liljegren