Originally Posted by
Petr Schreiber
Hi Phil,
I am really happy it works for you!,
Petr
Hooray - it works!!! I was so close before but Petr's example has helped me a great deal to get it to work.
It was even easier than I had thought
Here is the video of it WORKING GREAT!!!
YES
'for editor script coding control find buttons
Global laststr As String
Global occurrence As Long Value=1
'findResp() is called when user presses [FindText] button
'627 - editbox control for search text
'620 - Richedit control
'hDlg - window containing richedit control
'==========================
Function findResp() As Long
Local x, linebreaks As Long
'get text from find textbox
Control Get Text hDlg, 627 To searchstr
'if no text typed by user
If searchstr="" Then
laststr=""
occurrence=1
MsgBox hdlg, "Please type in a string to search for", %MB_ICONWARNING, "Information"
Exit Function
End If
'check if text same as last time
If laststr<>searchstr Then
occurrence=1
End If
'copy searchstr into laststr
laststr=searchstr
'try and find position and occurrence of text
x=InStr(response, searchstr, occurrence)
' if string not found...
If x=0 Then
MsgBox hdlg, "Could Not Find"+$CRLF+$DQ+searchstr+$DQ, %MB_ICONASTERISK,"Information"
laststr=""
occurrence=1
Exit Function
End If
'count number of linebreaks from start to position
linebreaks=ParseCount(Mid$(response,1,x), Any $LF)
'subtract number of lnebreaks from position
x =(x-linebreaks)
'highlight occurence of found string
If x=1 Then
Control Send hdlg,620, %EM_SETSEL, x-1, x+Len(searchstr)-1
Else
Control Send hdlg,620, %EM_SETSEL, x, x+Len(searchstr)
End If
Control Set Focus hdlg, 620
'In case user tries to find next occurrence of same string
Incr occurrence
End Function
'==========================
' When exiting Window dialog following vars are reset:
' laststr=""
' occurrence=1
catventure/Phil.
Bookmarks