how can i limit a user to enter 10 digit no like telephone no in textbox without using regular expressions?????

from the properties of that textbox change MaxLength=10
or textbox changed event like this:
if textbox1.text.length > 10 then
msgbox "just 10 digit!"
end if

I would rather choose KeyPress event, where you can use "e" parameter and set its Handled property:

Private Sub textBox1_KeyPress(sender As Object, e As KeyPressEventArgs)
	If textBox1.Text.Length >= 10 Then
		If e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End If
End Sub

from the properties of that textbox change MaxLength=10
or textbox changed event like this:
if textbox1.text.length > 10 then
msgbox "just 10 digit!"
end if

ohh thnk u sir,but is there any other way to add validation coz i have tried what u sugggest like:
if textbox1.text.length > 10 then
msgbox "just 10 digit!"

it means when i just enter 11th digit it pops up this message but takes that digit(11) too coz i dont want to change maxlength property.so is there any other way to do that without changing properties..

Go and try my example code!!! It will not take more then 10 characters!!
Thats why we have key events.

okey try this :)
If TextBox1.Text.Length > 10 Then
MsgBox("no more 10 !")
TextBox1.Text = Strings.Left(TextBox1.Text, TextBox1.Text.Length - 1)
End If

I would rather choose KeyPress event, where you can use "e" parameter and set its Handled property:

Private Sub textBox1_KeyPress(sender As Object, e As KeyPressEventArgs)
	If textBox1.Text.Length >= 10 Then
		If e.KeyChar <> ControlChars.Back Then
			e.Handled = True
		End If
	End If
End Sub

thank u very 2 much. i appreciate ur concern.. it worked...u r really my helping hands..

okey try this :)
If TextBox1.Text.Length > 10 Then
MsgBox("no more 10 !")
TextBox1.Text = Strings.Left(TextBox1.Text, TextBox1.Text.Length - 1)
End If

i m really glad as i m getting +ve responses from my frnds all over the world. i really appreciate ur concern sir,it also worked with a lil modification by changing "right" with "left
Thnk u sir and always keep helping...

hi..im ruby
can i ask some favor?
can u help me to solve some program about conversion in number into words?
i need the whole codes for this program and what properties i will used and how to show the output..
please...thank you

thank you.................

Hi ruby,
Please dont post in Someone else thread. And it is already solved. please open other thread.

You could use a masked text box and set the mask to 10 characters

Hi guys am varney W Carter am having a problem with my text box validation for credit card can someone please help me out this is what I did
Private Sub txtcredit_TextChanged(sender As Object, e As EventArgs) Handles txtcredit.TextChanged

    Dim credit As String

    If Not IsNumeric(txtcredit.Text) Then
        MessageBox.Show("This area is only for credit card Number")
        txtcredit.Text = ""
        credit = txtcredit.Text
    End If

    If txtcredit.Text = String.Empty Then
        MessageBox.Show("Please enter your credit card detile")
    ElseIf txtcredit.Text.Length < 16 Then
        cmdcongrate.Enabled = False
    ElseIf txtcredit.Text = String.Empty = True Then
    ElseIf txtcredit.Text.Length < 16 = True Then
        MessageBox.Show("You have enter less than 16 digits for your credit card ")
    ElseIf txtcredit.Text.Length > 16 = True Then
        MessageBox.Show("Your credit card number should not be more than 16 characters")

    End If
    cmdcongrate.Enabled = True

Don't hijack old solved threads! Start a newone.