标题:下列代码只能得到text1中的总行数,如何得到第n行的数据呢?求指教。。
只看楼主
liu0033546
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2013-3-25
结帖率:100%
已结贴  问题点数:20 回复次数:3 
下列代码只能得到text1中的总行数,如何得到第n行的数据呢?求指教。。
Const EM_GETLINE = &HC4
Const EM_LINELENGTH = &HC1
Const EM_LINEINDEX = &HBB
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()

Text2.Text = SendMessage(Text1.hWnd, EM_GETLINECOUNT, 0&, 0&)

End Sub
搜索更多相关主题的帖子: 如何 
2013-04-03 18:33
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4912
专家分:29900
注 册:2008-10-15
得分:10 
我不会用API。

Public Function getstr(str1 As String, index As Long) As String
Dim fj() As String
fj = Split(str1, vbCrLf)          '分解成一行一行
If index>0 and index < UBound(fj)+2 Then      '在总行数的范围内
    getstr = fj(index - 1)        '取结果
Else                              '否则返回空
    getstr = ""                  
End If
End Function

授人于鱼,不如授人于渔
早已停用QQ了
2013-04-03 19:07
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
得分:10 
程序代码:
Public Function Edit_GetLine(ByVal hWndControl As Long, ByVal nLine As Long) As String
    Dim nRet As Long
    ReDim bTmp(1024) As Byte
    bTmp(1) = 4
    nRet = SendMessage(hWndControl, &HC4, nLine, bTmp(0))
    If nRet Then
        Edit_GetLine = StrConv(Left$(bTmp, InStr(1, bTmp, vbNullChar) - 1), vbUnicode)
        'Edit_GetLine = Left$(bTmp, nRet) 'unicode SendMessageW
    End If
End Function
2013-04-03 20:21
liu0033546
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2013-3-25
得分:0 
回复 2楼 风吹过b
谢谢
2013-04-03 22:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-402985-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.414555 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved