-1

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
3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by Dili1234
Featured Replies
  • 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](http://msdn.microsoft.com/en-us/library/11405hcf(v=vs.71).aspx) … Read More

  • 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 … Read More

2

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.

1

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
0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.