How to select the contents of a textbox once it is activated?

前端 未结 10 2233
灰色年华
灰色年华 2020-12-06 05:16

I have this simple Userform, where I only have TextBox1 and TextBox2. I enter some text in both of them. Assume the focus is on (the cursor is in)

10条回答
  •  悲&欢浪女
    2020-12-06 06:05

    use this

    Private Sub TextBox1_Enter()
        With TextBox2
            .ForeColor = vbBlack
            .Font.Bold = False
        End With
        With TextBox1
            .ForeColor = vbRed
            .Font.Bold = True
        End With
    End Sub
    
    Private Sub TextBox2_Enter()
        With TextBox1
            .ForeColor = vbBlack
            .Font.Bold = False
        End With
        With TextBox2
            .ForeColor = vbRed
            .Font.Bold = True
        End With
    End Sub
    

提交回复
热议问题