Using tom interface to search a RichTextBox
by Just Me » Sun, 15 Aug 2004 02:38:30 GMT
I want to search a RichTextBox using a Regular Expression.
I've tried it using the tom interface but can't make it work.
That is, it works for whole words and for case but not for regular
expresions.
Below is a little of the code.
Thanks for any help.
Dim IDocument As tom.ITextDocument =
TextControl1.GetOLEInterface()
-snip
If chkWholeWords.Checked Then lFlags = Flags.MatchWord
If chkMatchCase.Checked Then lFlags = lFlags Or Flags.MatchCase
If chkRegularExpressions.Checked Then lFlags = lFlags Or
Flags.MatchPattern
Select Case aFindType
Case gFIND_FROM_THE_END
lSearchRange = GetCtlEdit(Me).TxtRangeAll
lintFoundPos = FindText(lSearchRange,
cboFindStr.Text, -lSearchRange.StoryLength, lFlags)
Case gFIND_FROM_THE_START
--snip
Private Function FindText(ByRef aRange As tom.ITextRange, ByVal aFindString
As String, ByVal aCount As Integer, ByVal aFlags As Integer) As Integer
If aCount = 0 Then
FindText = 0
Else
If aCount < 0 Then
FindText = aRange.FindTextEnd(aFindString, aCount, aFlags)
If FindText > 0 Then aRange.Start = aRange.End - FindText
Else
FindText = aRange.FindTextStart(aFindString, aCount, aFlags)
If FindText > 0 Then aRange.End = aRange.Start + FindText
End If
End If
End Function
Similar Threads:
1.Adding a File Search using a Registry Search value for the Folder property
Using Setup and Deployment project in Visual Studio 2005, I'm trying
to find the version on a file as a launch condition, but first I need
to find the location of the file in the registry.
I created a Registry Search and got the path I wanted.
I used this path to fill in the Folder property on a File Search.
This did not work for me because it appears that searching the target
machine searches the file system first, then the registry. Is this
assumption correct? Is there a workaround?
Thanks
2.Using registry search property in launch condition in a file search
I'm trying to take a path extracted from a registry key and use that
path to search for a specific file. I have a registry search that finds
the key and successfully extracts the path. I gave it a property name
PATHVALUE. In my file search, I'm trying to set the folder value to
[PATHVALUE]. However, this does not seem to work. My search depth is
correct and I currently have no values for any of the Min/Max
properties.
Is what I want to possible? I'm trying to cover the case where the user
does not install the file in the Program Files folder.
Thanks.
Tim
3.Search Files using OS Search
Is it possible to call the OS Search (Start/Search) from a windows
form application?
What I'm looking is to develop an interactive cd using vb.net with
search capabilities. The cd will have some pdf, word , excel and html
documents, and what I need is to have the possiblity to search for
some text inside these files (the same that I can do with the windows
search)
Thank in advance
Juan Miguel Lavista
4.How to search word in a richtextbox?
Hi,
Is there a quick easy way to search a text for words in richtextbox?
I would like to make it work as a word document, as the having Find, Find
Next by right click the richtextbox. THe words will be highlighted and the
focus wil move to that part of ricktextbox after each search.
Any suggestions?
Thanks a lot
Chris
5.Searching a RichTextBox
Hi
I have a richtextbox and I want the users to be able to search for text within the control. I would think that the richtextbox.find() would work, but I can't figure out how to get the textbox to scroll down and highlight the search text. Any suggestions?
6. using ITTAPI interface / determing which interfaces a dll exposes
7. Interface features implemented without using Interface
8. using EM_GETRECT vs. using EM_GETLINECOUNT with a RichTextBox