Link to home
Start Free TrialLog in
Avatar of nashuald
nashuald

asked on

Number of lines in a multiline textbox

How can I get the number of lines typed in a multiline textbox control?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

ASKER CERTIFIED SOLUTION
Avatar of vb_elmar
vb_elmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or if you want a very un-orthodox method:

dim strString as string
dim numLines as integer
dim myArray() as string
strString = text1.text
myArray() = Split(strString,vbcrlf)
numLines = myArray.UBound


msgbox "The text box has : " & numLines & " Lines"


I do not recommend using this method in any commerical application.

Brian
Brian: the split method only returns the number of hard breaks (via the crlf characters), but not those lines that are wrapped by the length of the line...
angelIII: You are very right.

I was just providing it as an example. Nothing more. I would never recommmend anything like that in a serious application.


Brian
Avatar of nashuald
nashuald

ASKER

Thank's everybody!