7
Contributors
14
Replies
32
Views
5 Years
Discussion Span
Last Post by hhhhhhhhhh
0

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

0

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

Edited by Mitja Bonca: n/a

0

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..

0

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

Edited by mustibh: n/a

0

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..

0

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...

0

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

0

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

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.