Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Textbox and cursor placement after TextChanged

I have a sub that seems to work fine but after I do txtwhatever = txtwhatever & "-" it works but it places the cursor in the front of the textbox again which of course messes up the number if you are typing it straight in.
How can I format the text ie: "111-222-333" while the number is being entered without having the cursor placed at the front of the textbox after each event.

   
Private Sub txtFullSocial_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFullSocial.TextChanged
        If txtFullSocial.TextLength = 3 Then
            txtFullSocial.Text = txtFullSocial.Text & "-"
        ElseIf txtFullSocial.TextLength = 6 Then
            txtFullSocial.Text = txtFullSocial.Text & "-"
        Else
            Exit Sub
        End If
    End Sub
0
Matrix1000
Asked:
Matrix1000
1 Solution
 
flavoCommented:
add
Me.txtFullSocial.Select(Me.txtFullSocial.Text.Length, 1)

after you finished "playing" with the text

Seems to work for me :-)

Dave
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now