Function findResp() As Long
Local numlines As Long ' for number of lines in richedit control
Local i As Long ' to store number in for/next loop
Local lineindex As Long ' index # of the first visible line
Local charindex As Long ' index of the first character on that line
Local linetextlen As Integer ' length of that line (note the data type!)
Local tempstr, tempstr2 as string 'to hold search string and linetext
Local linetext As String ' receives the line's text (HOW to do???)
'first get search string from Find editbox
Control Get Text hdlg, 627 To tempstr
'If empty findstring then exit
If tempstr="" Then Exit Function
'get total # of lines
Control Send hdlg, 620, %EM_GETLINECOUNT,0,0 To numlines
'get # of first visible line of control
Control Send hdlg, 620, %EM_GETFIRSTVISIBLELINE, 0, 0 To lineindex
'Check all lines from first visible to end of richedit text
For i=lineindex To numlines
' get line number and length of line text
Control Send hdlg, 620, %EM_LINEINDEX,lineindex, 0 To charindex
Control Send hdlg, 620, %EM_LINELENGTH, charindex,0 To linetextlen
linetext = (IIf(linetextlen >= 2, linetextlen, 2))
'*************
'How to copy the actual TEXT of the line into tempstr2?
'Following line does not work. How do I make it work?
Control Send hdlg, 620, %EM_GETLINE,i, linetext To tempstr2
'*************
'When line text is in tempstr2 Check to see if search string is in it.
If InStr(tempstr2,tempstr)>0 Then
respscroll=i
Exit For
End If
Next i
'If line contains it - scroll down To found Line And Show At top of richedit
If respscroll>0 Then
MsgBox hdlg, "Search Result...", %MB_ICONASTERISK,"Information"
Control Send hdlg,620,%EM_LINESCROLL,0,(respscroll-lineindex)
Control Send hdlg,620, %EM_LINEINDEX,respscroll , 0
'Control Send hdlg,620 ,%EM_SCROLLCARET, 0, 0
Exit Function
End If
MsgBox hdlg, "Not Found", %MB_ICONWARNING, "Information"
End Function
This may be a way; may not be the best way however.
Bookmarks