I want enter the telephone no into text box like this 022-1234567

how to set the textbox commands to get like this...........

Comments
Please be more descriptive in your thread titles

Hi,

Do you mean you get a phone number and you want to display in that format?

dim MyPhoneNumber as string
....
Textbox1.Text = MyPhoneNumber.SubString(0,3) &"-" &MyPhoneNumber.SubString(3)

Or do you want to force users to enter in that format? Or Both?
In that case you need The Masked Edit Textbox
Or you will have to use A Validation Class - I never used one before though.

Try this ... will automatically unsert the hyphen as they type:

'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)
        End If
    End Sub

Thank you........ to both .mikeybware & G_Waddell
sorry i couldn't explain the problem clearly........

This question has already been answered. Start a new discussion instead.