怎样得到文本框(TextBox)中的文本行数
来源:岁月联盟
时间:2004-10-16
把以下API函数的声明添入模块文件的general declarations区域。
Option Explicit
Public 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
Public Const EM_GETLINECOUNT = &HBA
Form Code
Sub Text1_Change()
Dim lineCount as Long
On Local Error Resume Next
'得到/显示文本行数
lineCount = SendMessageLong(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
Label1.Caption = Format(lineCount, "##,###")
End Sub
注释:为了使本程序成功,请在设计阶段把文本框的Multiline属性设为True。
上一篇:使用公共语言运行库强制代码访问权
下一篇:XML介绍