I want enter the telephone no into text box like this 022-1234567
how to set the textbox commands to get like this...........
I want enter the telephone no into text box like this 022-1234567
how to set the textbox commands to get like this...........
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........
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.