+ Reply to Thread
Results 1 to 7 of 7

TextBox BackColor

  1. #1
    Registered User
    Join Date
    10-11-2004
    Posts
    18

    TextBox BackColor

    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?



    Lenny

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    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
    Last edited by mangesh_yadav; 06-15-2005 at 08:17 AM.

  3. #3
    Registered User
    Join Date
    10-11-2004
    Posts
    18

    TextBox BackColor

    Hi,

    Thanks for replying.

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

    Sorry about the confusion.

    Lenny

  4. #4
    keepITcool
    Guest

    Re: TextBox BackColor

    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 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?
    >
    >
    >
    > Lenny


  5. #5
    Registered User
    Join Date
    10-11-2004
    Posts
    18

    TextBox BackColor

    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

  6. #6
    keepITcool
    Guest

    Re: TextBox BackColor


    create a class for those textboxes.
    described:
    http://www.j-walk.com/ss/excel/tips/tip44.htm



    --
    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


  7. #7
    Registered User
    Join Date
    10-11-2004
    Posts
    18
    That's great, thanks

    Lenny

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1