Link to home
Start Free TrialLog in
Avatar of Matrix1000
Matrix1000

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial