How do you count the lines from a text box or a richtextbox... ?
Printable View
How do you count the lines from a text box or a richtextbox... ?
Use the EM_GETLINECOUNT message.
[Edited by Megatron on 09-08-2000 at 07:10 PM]Code:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Sub Command1_Click()
Dim iLines As Integer
iLines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
MsgBox ("There are " & iLines & " lines in Text1")
End Sub
wow... is that easy or what!!!
Good lord megatron... how do you know all these stuffs...
Anywayz thanks alot for the code
This returns the total line count only. What if I want to count only to the cursor? Is there a way to customize for that functionality?
Hope ya still need it! (or actaully I hope you allready have the answer but well...)
http://www.mvps.org/vbnet/code/texta...urrentline.htm
That's it. Nope, I hadn't found an answer yet. Thanks.