Hi in my country we can phone anyone by only 7 number... Eg 2345897
and sometimes we represent it in this format 234-5897 by a - (negative)..

i want to tell the txtPhoneNumber that after 3 numbers ahve been entered a negative should be place and it should comes automatically ...
i do not want any user to press on the negative frm the keyboard..

I need help 4 this ..

You can use regular expression to validate user input, in your case your regular expression'd be ^\d{3}-\d{4}$
So, on your btn validate click event handler you can check if user enters valid phoen number or not

if Regex.IsMatch(txtPhoneNumber.Text, textBox1.Text)
then
MessageBox.Show("Correct")
else
MessageBox.Show("Wrong")

This code if u want to add - after 3 numbers :

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text.Length = 3 Then
            TextBox1.Text = TextBox1.Text + "-"
        End If
    End Sub

This Following code if u want - (negative) will added after user input 7 numbers.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text.Length = 7 Then
            TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, 3) + "-" + Microsoft.VisualBasic.Mid(TextBox1.Text, 4, TextBox1.Text.Length)
        End If
    End Sub
Comments
awesome

But this issue can be solved by using masked text box.
if we use no need to write code also

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