0

I'm new to VB.net and I'm stumped as to how to do this.
I want to find specific text in a richtextbox and color it red, but the problem is that I only want it to search (on each line) at the 15th character to the end of the line.

Here is my code:

    lspos = 1
    strWord = cboSixth.Text
    lPos = InStr(lspos, rtxtRichTextBox1.Text, strWord, vbTextCompare)
    While lPos > 0
        With rtxtRichTextBox1
            .SelectionStart = lPos - 1
            .SelectionLength = Len(strWord)
            .SelectionColor = Color.Red
        End With
        lspos = lPos + 1
        lPos = InStr(lspos, rtxtRichTextBox1.Text, strWord, vbTextCompare)
    End While
    rtxtRichTextBox1.SelectionStart = Len(rtxtRichTextBox1.Text)
    rtxtRichTextBox1.SelectionLength = 0
    rtxtRichTextBox1.SelectionColor = Color.Black
2
Contributors
1
Reply
18
Views
3 Years
Discussion Span
Last Post by Bang_1
0
           With rtxtRichTextBox1
Dim tempArray() as String
tempArray = rtxtRichTextBox1.Lines
For each temp in tempArray
  .SelectionStart = lPos - 1
        .SelectionLength = Len(strWord)
        .SelectionColor = Color.Red
    End With
    next
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.