Tools Links Login

Count number of lines/returns in a textbox

Simply counts the number of lines in a textbox (the textbox should be multiline=true, otherwise it is pretty useless). Put this in a module so it can be reused.

Original Author: Jono Spiro

Inputs

USAGE--countLines(the textbox)
EXAMPLE--countLines(text1)

Returns

Returns the number of lines in a textbox.

Code

Public Function countLines(textBox As textBox) As Long
Dim A%, B$
A% = 1
B$ = textBox.text
Do While InStr(B$, Chr$(13))
  A% = A% + 1
  B$ = Mid$(B$, InStr(B$, Chr$(13)) + 1)
Loop
countLines = CStr(A%)
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 88 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.