I have a richtextbox on my form and currently have made a simple syntax highlighting for it. It works great with a small amount of text but as the text amount increases it starts flashing and locks the textbox while typing.

This is my current code. I call the sub on the textchanged event.

Basically what happens is I have a list of words that it checks for and if it finds it, it colors the word.

Code:
    Sub ColorCode()
            Dim selectStart As Integer = rtbCode.SelectionStart
            rtbCode.Select(0, rtbCode.Text.Length)
            rtbCode.SelectionColor = Color.Black
            rtbCode.DeselectAll()
            For Each oneWord As String In event_list
                Dim pos As Integer = 0
                Do While rtbCode.Text.ToUpper.IndexOf(oneWord.ToUpper, pos) >= 0
                    pos = rtbCode.Text.ToUpper.IndexOf(oneWord.ToUpper, pos)
                    rtbCode.Select(pos, oneWord.Length)
                    rtbCode.SelectionColor = Color.DarkBlue
                    pos += 1
                Loop
            Next
            rtbCode.SelectionStart = selectStart
            rtbCode.SelectionLength = 0
    End Sub
Anyway to improve it so it doesn't flash or anything would be great.