Hey
How do I count how many lines there are in a RichTexBox
Thanks
Printable View
Hey
How do I count how many lines there are in a RichTexBox
Thanks
VB Code:
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Const EM_GETLINECOUNT = &HBA 'To Get How Many Lines In Text Box, in the textbox change event, put Dim lineCount As Long On Local Error Resume Next lineCount = SendMessageLong(RichTextBox1.hwnd, EM_GETLINECOUNT, 0&, 0&) Label1 = Format$(lineCount, "##,###")
[code]
'VB only way
function linecount() as long
Dim a() as string
a = Split(rtb1.Text,vbcrlf)
linecount=ubound(a+1)
end function
Thanks, now I can continue my chat room:D
what about vbLf's Jim? That will only count Cr's :p