|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Textbox Lines LimitIs there any way to put a limit on the number of lines in a textbox? (appart
of number of characters) Thank you, Samuel Try counting the number of Returns the user enters, after which stop him
entering 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 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 > 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. -- Show quoteHide quoteDennis in Houston "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 > > > > > Stuart Nathan wrote:
> doesn't return .count It's a string array so you can use TextBox1.Lines.Length> nor can you use Ubounds
CODE to Test ALPHA Transparency
not sure how to describe this question... Updating field in table Please. join 2 tables and datagrid form.load don't exist anymore ? Read value of all columns from datatable together CreateObject error Printing to screen in VB.NET RichTextBox special characters? Failed to decrypt |
|||||||||||||||||||||||