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 Const EM_GETLINE = &HC4
'这段代码是如果超过10行,就把前面的几行去掉,最后剩下10行
'你可以把以下这段代码放在你的定时器中。
Private Sub Command1_Click()
Dim nCount As Long
Dim s As String
s = String(256, " ") ’一行的最大长度,可以修改
nCount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
Do Until nCount < 10
nCount = SendMessage(Text1.hwnd, EM_GETLINE, 0, ByVal s)
Text1.SelStart = 0
Text1.SelLength = nCount + 2
Text1.SelText = ""
nCount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
Loop
End Sub
dim i as integer,b as integer,str as string
for i= 0 to len(text1.text)
str=left(text1.text,i)
if instr(str,vbcrlf) then exit for
next i
if instr(text1.text,vbcrlf) then
b=b+1
end if
if b>10 then
d=clng(len(text1.text)-len(str))
text1.text=right(text1.text,d)
b=10
end if