need some help guys im trying to put a hyphen between a number for the telephone number but i want to use the keypress or textchanged i already done it using the button so im trying to use the textbox rightnow but after the hyphen is been inserted to a specific location it always go back to the starting point of the textbox.

tnx begg already solve it a while ago with browsing through the different thread in the forum

Try doing this (Formats the phone numbers to ###-###-####):

         Private Sub PhoneTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhoneTextBox.TextChanged
            If PhoneTextBox.TextLength = 3 Then
                PhoneTextBox.Text = PhoneTextBox.Text + "-"
                'Put the cursor after the last character
                PhoneTextBox.SelectionStart = Len(PhoneTextBox.Text)
            ElseIf PhoneTextBox.TextLength = 7 Then
                PhoneTextBox.Text = PhoneTextBox.Text + "-"
                PhoneTextBox.SelectionStart = Len(PhoneTextBox.Text)
            End If
        End Sub
This question has already been answered. Start a new discussion instead.