title: Inserting text into a textbox at the cursor position VB
body: <p>I am trying to work out how I can insert the string "End" into my textbox at a specific cursor point? 
  (where the '???' is in the code below)</p>
  
  <p>As you can see by the code below this will happen when the user clicks return on the keyboard within the textbox.</p>
  
  <p>I have the code to get the cursor index which is being stored as integer 'intcurrentcolumn'.</p>
  
  <p>Thanks</p>
  
  <pre><code> Private Sub Enter_Click(ByVal Sender As System.Object, ByVal k As System.Windows.Forms.KeyEventArgs)
  
       Dim MyTextBox As TextBox = sender
       Dim intindex As Integer
       Dim intcurrentcolumn As Integer
       Dim NewString As String
  
       If k.KeyCode = Keys.Return Then
  
          k.SuppressKeyPress = True
  
          intindex = MyTextBox.SelectionStart
          intcurrentColumn = intindex - MyTextBox.GetFirstCharIndexFromLine(intcurrentLine)
  
          If intindex = MyTextBox.Text.Length Then
  
           NewString = MyTextBox.Text &amp; "&lt;End&gt;"
  
          Else: 
  
          ???
  
          End If
  
          MyTextBox.Text = NewString
  
          'Sets cursor to end of textbox
          MyTextBox.Select(MyTextBox.Text.Length, 0)
  
        End If
  </code></pre>
  
  <p><strong>Thanks In Advance !</strong></p>