Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CODE HELP!!!

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Hi there,
Can any one help me regarding the API Function. Iam having a multi-lined Text Box control with vertical & horizongal scroll bars in the form. Now I want to read a particular line of text using an API Function. That is, if I want to get the text present in 8th line out of 200 lines of text present, then generally I will get the text into an array(thru SPLIT function) then refer the array element as per the line number:-

Private Function get_Line_Text(TxtBox As Object,LNo as integer) As String
Dim TBtext as string
TBtext=split(TxtBox.Text,vbcrlf)
get_Line_Text=TBText(Lno-1)
End Function

Hope You guyz have got my point. I want an API function that can directly give me the text of particular line in a multi-lined text box control. If any one of You guyz know an API that can sort out my problem, plz let me know. Thankz in advance of Your interest.

With Regards,
Nagalinga Reddy Kapu
 
Sure. Not necessarily better though. Here's an example:
[tt]
Option Explicit
Private Const EM_GETLINE = &HC4
Private Const EM_LINELENGTH = &HC1
Private Const EM_LINEINDEX = &HBB


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 ' generic declaration

Private Sub Command1_Click()
Debug.Print GetTextBoxLine(18)
End Sub

Private Function GetTextBoxLine(ByVal lLine As Long) As String
Dim LineBuffer() As Byte

ReDim LineBuffer(SendMessage(Text1.hwnd, EM_LINELENGTH, SendMessage(Text1.hwnd, EM_LINEINDEX, lLine, 0), 0))
LineBuffer(0) = UBound(LineBuffer)
SendMessage Text1.hwnd, EM_GETLINE, lLine, LineBuffer(0)

GetTextBoxLine = StrConv(LineBuffer, vbUnicode)
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top