Change clolor of text box with combo box selection

foxtet

Registered User.
Local time
Today, 18:14
Joined
May 21, 2011
Messages
129
I need color of text box to be changed according to the selected value of combo box
for example

cboClor.vale = red......txtBox1.backclor = vb red
cboClor.vale = blue......txtBox1.backclor = vb blue
cboClor.vale = orange......txtBox1.backclor = vb orange
cboClor.vale = No color......txtBox1.show = false

I need your help to find a solution to this.

foxtet
 
You will need some code in the Combo's On Change event along the lines of;
Code:
Select Case Me.cboClor

Case "Red"
     Me.txtBox1.backcolor = vbRed

Case "Blue"
     Me.txtBox1.backcolor = vbBlue

Case "Orange"
     Me.txtBox1.backcolor = 17919

Case Else
     Me.txtBox1.Visible = False

End Select

Note vbOrange is not a valid colour constant (hence 17919) so will return black other valid colour constants are;

vbBlack
vbRed
vbGreen
vbYellow
vbBlue
vbMagenta
vbCyan
vbWhite

Or check this link for numeric constants for other colours
 
... you will also need to put that code in the Form's On Current event.
 

Users who are viewing this thread

Back
Top Bottom