Im trying to write an Editor for "LTSpice" Syntax, because i need it for my job. I Already have a method to find and color the keywords, which i saved in a list(Of String). But this method is way to slow and when i have a lot of words it flickers.
This is my method :
Code:
Public Sub HighlightSyntax()
Dim words As New List(Of String)
words.Add("test ")
If RichTextBox1.Text.Length > 0 Then
Dim selectStart As Integer = RichTextBox1.SelectionStart
RichTextBox1.Select(0, RichTextBox1.Text.Length)
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.DeselectAll()
For Each Wort As String In words
Dim pos As Integer = 0
Do While RichTextBox1.Text.ToUpper.IndexOf(Wort.ToUpper, pos) >= 0
pos = RichTextBox1.Text.ToUpper.IndexOf(Wort.ToUpper, pos)
RichTextBox1.Select(pos, Wort.Length)
RichTextBox1.SelectionColor = Color.Blue
pos += 1
Loop
Next
RichTextBox1.SelectionStart = selectStart
RichTextBox1.SelectionLength = 0
End If
End Sub
greez DXStriker







