|
-
Dec 1st, 2001, 07:26 AM
#1
Thread Starter
Junior Member
In Need of Help
Is there any method from which I can get the line count in a
RichTextBox?
-
Dec 1st, 2001, 10:07 AM
#2
I'm not sure if this is what you are after.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim LineCount
On Error GoTo LineErr
LineCount = Split(RichTextBox1.Text, vbCrLf)
MsgBox "Line count = " & UBound(LineCount) + 1
Exit Sub
LineErr:
MsgBox "Line count = 0"
End Sub
-
Dec 1st, 2001, 10:11 AM
#3
PowerPoster
You can also use API like this:
VB 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
Dim linecount As Integer
'////////////////////////////////////////////////////////
linecount = SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0, 0)
MsgBox linecount
-
Dec 1st, 2001, 10:14 AM
#4
Conquistador
Faster:
VB Code:
Private Const EM_GETLINECOUNT = &HBA
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 Sub Command1_Click()
MsgBox SendMessage(Me.RichTextBox1.hwnd, EM_GETLINECOUNT, ByVal CLng(0), ByVal CLng(0))
End Sub
-
Dec 1st, 2001, 10:14 AM
#5
Damn API again, I have to learn about them someday.
-
Dec 1st, 2001, 10:23 AM
#6
Conquistador
oh well,
win some lose some
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|