VB 取得文本框中的行数
以下方法将文本框中内容读入字符串数组中。行数即为Ubound(t)+1
Dim t() As String, i As Integer
t = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(t)
Debug.Print t(i)
Next
如果只需要行数,不需要读出,可用以下方法:
*API函数声明
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const EM_GETLINECOUNT = &HBA
注释:在程序中调用
LineCnt = SendMessage(ctl.hwnd, EM_GETLINECOUNT, 0, 0)
注释:LineCnt即为此TextBox的行数。
- 上一篇:vb 获得标题栏的高度
- 下一篇:VB 自定义消息框上的按钮的文字