Search RichTextBox (and regular textbox) with multiple strings...
Posted on 2003-03-16
I am looking to search a RichTextBox for multiple strings.
(could be a TextBox, too, but this part of the project entails using a RichTextBox)
Text1.Text = "First Text"
Text2.Text = "Second Text"
Text3.Text = "Third Text"
cboReplace.AddItem = "This Text"
cboReplace.AddItem = "That Text"
cboReplace.AddItem = "All Text"
rtfText.Text = "This First Text is Right before the Second. The Second Text is right after the First. The Third Text, of course, will be last, however, if you loop through the RichTextBox Control, You'll be starting back at the First again. Then, You'll go to the Second Text."
Now, what I'm trying to do is find all strings that match the entire contents of the RichTextBox above. Hence, "First Text" Not "First" Not "Text".
For each instance of Text1.Text I find, I will assign -1 points.
For each instance of Text2.Text I find, I will assign -5 points.
For each instance of Text3.Text I find, I will assign -3 points
The Totals according to the criteria above found in the search are:
Text1.Text = -1 pts.
Text2.Text = -10 pts.
Text3.Text = -3 pts.
making the Total -14 pts.
After I find the specific text, I would like to prompt the user,
"The word '" & Text1.Text & "' has been found (Number of Times)." & vbcrlf & _
"Would You like to Replace the Text?"
If User Chooses Yes, they will choose 3 options from the options added to a Combobox named cboReplace to replace the text with (hence, user makes a choice to either not replace the text, or replace the text with a choice in the combo box.
If they choose not to replace the text, the points still remain, if they choose to change the text, the text in the rtfText.Text changes accordingly and the points will not be counted in the Total.