TextBox BackColor

  • Thread starter Thread starter Lenny_821
  • Start date Start date
L

Lenny_821

Hi All,

I've got about 10 TextBox's on a UserForm. How can I change the
BackColor of the TextBox (Double Click) with 1 Code?

:confused: :confused:

Lenny
 
This is probably what you need....

Private Sub CommandButton1_Click()

For Each oCtl In Me.Controls
If TypeName(oCtl) = "TextBox" Then
oCtl.BackColor = 255 ' change the color to red
End If
Next oCtl

End Sub



A similar query was answered by Bob Phillips in thread:
http://excelforum.com/showthread.php?t=378495


Mangesh
 
Hi,

Thanks for replying.

What I am looking for is when I double click on the TextBox itself.

Sorry about the confusion.

Lenny
 
sample:

Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With TextBox1
Select Case .BackColor
Case vbWindowBackground
.BackColor = vbRed
Case vbRed
.BackColor = vbGreen
Case vbGreen
.BackColor = vbWindowBackground
Case Else 'you shouldnt need this :)
debug.print .backcolor
stop
End Select
End With
End Sub





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Lenny_821 wrote :
 
Hi,

The examples I get only refers to 1 TextBox.

What i am looking for is when any TextBox is double clicked it changes
the BackColor. And that in 1 code.

Lenny :) :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top