Hi, I am currently making a Syntax Highlighter.
How can I highlight certain text inside a RichTextBox ?
I am Currently Using This Code :
Public Function Highlight(ByVal highlightcolor As String, ByVal ParamArray WordsToFind() As Object) 'Loop through all the words you specified: For i As Integer = 0 To UBound(WordsToFind) RichTextBox1.Find(WordsToFind(i), RichTextBoxFinds.None) 'Determine which color the word must become: Select Case highlightcolor Case "red" RichTextBox1.SelectionColor = Color.Red Case "blue" RichTextBox1.SelectionColor = Color.Blue Case "green" RichTextBox1.SelectionColor = Color.Green End Select 'reset the selection RichTextBox1.SelectionLength = 0 Next i Return 1 End Function
but it will only Highlight 1 of the word I set / Change the whole text into the selected colour
Example :
'I wanted to Highlight "Hello" 'I put this code into RichTextBox_TextChanged: Highlight("blue","Hello") 'And It will Only highlight The First "Hello" inside my Text : 'Hello my name is XXX, Hello !
Any Ideas?
And, can I Highlight text between certain text / after certain text
Example :
'Highlight After the '
Or :
<!-- Highlight between these 2 tags -->
Please HELP Me !!