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

前端 未结 10 2250
灰色年华
灰色年华 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 05:43

    Private Sub UserForm_Initialize()                                                                
        TextBox1.SetFocus
        TextBox1.SelStart = 0
        TextBox1.SelLength = Len(TextBox1.Text)
    End Sub   
    

    Add this to the form's code

提交回复
热议问题