|
-
Oct 8th, 2016, 10:18 AM
#1
Thread Starter
Lively Member
Find Multiple Text In RtxtBox and Highlight
What I have is two Richtextboxes. One will have multiple lines of text that will be searched for in the other Richtextbox.
So let's say Richtextbox2.text has this:
Hello
My
Name
Is
All of those lines need to stand as a individual string that will be searched and highlighted in blue in Richtextbox1.
Hello friends and family, my last name is Haas and my first is Kory.
So every instance of Hello, My, Name, Is should be highlighted blue.
Hello friends and family, my last name is Haas and my first is Kory.
The code I am using to do this is one I tried to build myself and isn't work well, sometimes it will highlight the first couple instances and sometimes it'll only highlight one instance. I can't figure out what is wrong with my code but I'm thinking about starting completely from scratch. But I am completely open and thankful for all ideas and help.
Code:
If System.IO.File.Exists(Application.StartupPath & "\DUMP\CORE.txt") Then
Dim objreader As New System.IO.StreamReader(Application.StartupPath & "\DUMP\CORE.txt")
For index As Integer = 1 To CORE_Line_Count
Dim Find_X As String = objreader.ReadLine
MsgBox(CORE_Line_Count)
Dim lastindex = RichTextBox1.Text.LastIndexOf(Find_X)
index = 0
While index < lastindex
RichTextBox1.Find(Find_X, index, RichTextBoxFinds.None)
RichTextBox1.SelectionColor = Color.Blue
index = RichTextBox1.Text.IndexOf(Find_X, index) + 1
End While
'Textbox2.text = objreader.ReadToEnd
Next
objreader.Close()
End If
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|