KeyDown Event, TextBox Control, CurLine, CurTargetX, CurX, Text Properties Example
The following example tracks the CurLine, CurTargetX, and CurX property settings in a multiline TextBox. These settings change in the KeyUp event as the user types into the Text property, moves the insertion point, and extends the selection using the keyboard.
To use this example, follow these steps:
Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
TextBox2.Text = TextBox1.CurLine
TextBox3.Text = TextBox1.CurX
TextBox4.Text = TextBox1.CurTargetX
End Sub
Private Sub UserForm_Initialize()
TextBox1.MultiLine = True
TextBox1.Text = "Type your text here. User CTRL + ENTER to start a new line."
End Sub