aeolian20
Member
- Joined
- Feb 13, 2010
- Messages
- 12
- Programming Experience
- Beginner
I have hit a roadblock attempting to edit a RichTextBox and hoped someone had some insight.
This is the example text below:
a
b
hello
c
d
hello
e
f
hello
g
I would like to keep the 1st "hello". Then remove every other "hello" & the line above it. So it would read:
a
b
hello
c
e
g
I have managed to change the color of the 1st "hello" blue & every other one red w/ this code.
Dim findme As String = "hello"
Dim textend As Integer = RichTextBox1.TextLength
Dim index As Integer = 0
Dim lastindex As Integer = RichTextBox1.Text.LastIndexOf("hello")
While index < lastindex
RichTextBox1.Find(findme, index, textend, RichTextBoxFinds.None)
If index = 0 Then
Me.RichTextBox1.SelectionColor = Color.Blue
Else
Me.RichTextBox1.SelectionColor = Color.Red
End If
index = RichTextBox1.Text.IndexOf(findme, index) + 1
End While
Thanks for any insight.
This is the example text below:
a
b
hello
c
d
hello
e
f
hello
g
I would like to keep the 1st "hello". Then remove every other "hello" & the line above it. So it would read:
a
b
hello
c
e
g
I have managed to change the color of the 1st "hello" blue & every other one red w/ this code.
Dim findme As String = "hello"
Dim textend As Integer = RichTextBox1.TextLength
Dim index As Integer = 0
Dim lastindex As Integer = RichTextBox1.Text.LastIndexOf("hello")
While index < lastindex
RichTextBox1.Find(findme, index, textend, RichTextBoxFinds.None)
If index = 0 Then
Me.RichTextBox1.SelectionColor = Color.Blue
Else
Me.RichTextBox1.SelectionColor = Color.Red
End If
index = RichTextBox1.Text.IndexOf(findme, index) + 1
End While
Thanks for any insight.