# 有两个方法

Posted by Windows NT user on February 01, 1999 at 08:36:43:

In Reply to: 请问如何取得RichTextBox所显示的文字行数? posted by Chennet on January 29, 1999 at 23:49:44:

: 在RichTextBox,不像ListBox内有listcount的属性
: 请问如何取得RichTextBox所显示的文字行数?

第一:
把RichTextBox里的文字提取出来,然后用回圈数(提示:行与行之间是以vbCrLf分隔的)
第二:
Option Explicit
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 lineCount As Long
lineCount = SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0, ByVal 0&)
Debug.Print lineCount
End Sub
这个方法应比较快

Follow Ups:

- Thanks WindowsNT user Chennet 11:49:23 2/01/99 (0)