VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Count number of lines/returns in a textbox

by Jono Spiro (4 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

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.

Inputs
USAGE--countLines(the textbox) EXAMPLE--countLines(text1)
Code Returns
Returns the number of lines in a textbox.

Rate Count number of lines/returns in a textbox

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

Download this snippet    Add to My Saved Code

Count number of lines/returns in a textbox Comments

No comments have been posted about Count number of lines/returns in a textbox. Why not be the first to post a comment about Count number of lines/returns in a textbox.

Post your comment

Subject:
Message:
0/1000 characters