473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Textbox Lines Limit

Is there any way to put a limit on the number of lines in a textbox? (appart
of number of characters)

Thank you,
Samuel
Jun 5 '06 #1
6 1918
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

Jun 5 '06 #2
Try counting the number of Returns the user enters, after which stop him
entering
Jun 5 '06 #3

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" <sa************@ntlworld.com> schreef in bericht
news:uw**************@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

Jun 5 '06 #4
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
"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" <sa************@ntlworld.com> schreef in bericht
news:uw**************@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


Jun 6 '06 #5
doesn't return .count
nor can you use Ubounds
Jun 6 '06 #6
Stuart Nathan wrote:
doesn't return .count
nor can you use Ubounds


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

Jun 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
1
by: Sachin | last post by:
How to limit a TextBox control to a specific number of characters per line and number of lines? please guide -- sachin
3
by: Homer Simpson | last post by:
How do I convert a value in a textbox to a real number so I can perform some math ops on it? I understand I will need to validate the textbox's input to make sure it is a real number and not a...
2
by: ZZ | last post by:
Is there any limitaion of the number of lines for TextBox? How many lines can a TextBox have? Thanks!
7
by: Andrew | last post by:
VB .NET 2003, WinXP Pro: Adding text to a text box with the TextBox.AppendText method limits the amount of text in the textbox to 32K. I have a short program that uses the GetFiles function of...
4
by: Agnes | last post by:
How can I limit the line for the user to input in the "multiline - textbox ?" Thanks a lot. From Agnes
10
by: garyusenet | last post by:
I have a multiline textbox. The size of the text box should be 75 characters wide, and 5 lines in height like this: - <---75 characters--> <---75 characters--> <---75 characters--> <---75...
9
by: Phill W. | last post by:
VB.Net 2005 SP1 Windows Forms Application What's the fastest way to append text to a TextBox? I have an application that monitors data written to text files. It needs to scan some fairly...
0
by: tshad | last post by:
I seem to have hit some sort of limit of a textbox (multiline). It was working fine for a while, but now I am getting a strange error having nothing to do with the problem. I have a Function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.