Home All Groups Group Topic Archive Search About
Author
5 Jun 2006 1:35 PM
Samuel Shulman
Is there any way to put a limit on the number of lines in a textbox? (appart
of number of characters)

Thank you,
Samuel

Author
5 Jun 2006 4:38 PM
Stuart Nathan
Try counting the number of Returns the user enters, after which stop him
entering
Author
5 Jun 2006 4:41 PM
ag
I think it can be possible. Though I havnt tried it, but give it a try.

Declare a variable which will keep track of ur no of lines.
Then on the textBox's keydown/keypress event track "Enter" key and then
increment ur variable and check its value against your max no of lines.

Remember Enter key ASCII code is 13.

Thanks.
ag
Author
5 Jun 2006 8:16 PM
Michel Posseth [MCP]
count the number of occurences of environment.newline and take the action
you want to perform


here a small example that could do something after you have more as 5 rows

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged

If countsubstrings(TextBox1.Text, Environment.NewLine) = 5 Then

'do your stuff

End If

End Sub

Function countsubstrings(ByVal source As String, ByVal search As String)As
Integer

Dim count As Integer = -1

Dim index As Integer = -1

Do

count += 1

index = source.IndexOf(search, index + 1)

Loop Until index < 0

Return count

End Function



hope to have given you some inspiration



regards


Michel Posseth [MCP]
Show quoteHide quote
"Samuel Shulman" <samuel.shul***@ntlworld.com> schreef in bericht
news:uwxbhTKiGHA.4592@TK2MSFTNGP03.phx.gbl...
> Is there any way to put a limit on the number of lines in a textbox?
> (appart of number of characters)
>
> Thank you,
> Samuel
>
Author
6 Jun 2006 12:38 AM
Dennis
There is a textbox property called lines which returns an array of the text
box lines.  You might be able to do something with mytextbox.lines.count.
--
Dennis in Houston


Show quoteHide quote
"Michel Posseth [MCP]" wrote:

>
> count the number of occurences of environment.newline and take the action
> you want to perform
>
>
> here a small example that could do something after you have more as 5 rows
>
> Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles TextBox1.TextChanged
>
> If countsubstrings(TextBox1.Text, Environment.NewLine) = 5 Then
>
> 'do your stuff
>
> End If
>
> End Sub
>
> Function countsubstrings(ByVal source As String, ByVal search As String)As
> Integer
>
> Dim count As Integer = -1
>
> Dim index As Integer = -1
>
> Do
>
> count += 1
>
> index = source.IndexOf(search, index + 1)
>
> Loop Until index < 0
>
> Return count
>
> End Function
>
>
>
> hope to have given you some inspiration
>
>
>
> regards
>
>
> Michel Posseth [MCP]
> "Samuel Shulman" <samuel.shul***@ntlworld.com> schreef in bericht
> news:uwxbhTKiGHA.4592@TK2MSFTNGP03.phx.gbl...
> > Is there any way to put a limit on the number of lines in a textbox?
> > (appart of number of characters)
> >
> > Thank you,
> > Samuel
> >
>
>
>
Author
6 Jun 2006 11:25 AM
Stuart Nathan
doesn't return .count
nor can you use Ubounds
Author
6 Jun 2006 1:28 PM
Chris Dunaway
Stuart Nathan wrote:
> doesn't return .count
> nor can you use Ubounds

It's a string array so you can use  TextBox1.Lines.Length