title: Winform: Cursor in wrong location on backslash or delete
body: <p>I set up a sort of filter on my textBox in WinForms, to exclude particular characters from being entered by the client. However, I seem to be created new problems that I need help with fixing. </p>
  
  <p>a) Clicking BackSlash causes the cursor to move to the front of the string of characters, rather than remain at the correct position </p>
  
  <p>b) Subsequent clicks of BACKSLASH still causes deletion from the correct location but the cursor remains at the beginning of the string </p>
  
  <pre><code>Private Sub txtExp_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtExp.KeyPress
          Dim strtext As String = txtExp.Text 
              If (e.KeyChar = ChrW(Keys.Back)) Then
                  If (strtext.Length &gt; 0) Then
                      txtExp.Text = strtext.Substring(0, strtext.Length - 1)
                      txtExp.Update()
                  End If
              ElseIf (Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar) Or (e.KeyChar = "."))) Then
                  e.Handled = True
              Else
                  txtExp.AppendText(e.KeyChar)
              End If
      End Sub
  </code></pre>
  
  <p>What I would like instead is to have the cursor in the correct location at all times. How do I accomplish this please? </p>