Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax Highlighting..
#3
Here is a nice control that will handle that for you, if you don't want to program it yourself.

<!-- m --><a class="postlink" href="http://www.freevbcode.com/ShowCode.asp?ID=5176">http://www.freevbcode.com/ShowCode.asp?ID=5176</a><!-- m -->

But if you do want to program it yourself, it should look something like this:

Code:
Public Sub HighlightKeyWords(ByVal rtb As RichTextBox, ByVal words As List(Of String))
        Dim selection_original As Integer = rtb.SelectionStart
        For Each word As String In words
            If (rtb.Text.Contains(word)) Then
                Dim pos As Integer = rtb.Find(word)
                If (pos <> -1) Then
                    'The value was found and now has a position
                    rtb.Select(pos, word.Length)
                    rtb.SelectionColor = Color.Blue
                    'Now go back to our original selection
                    rtb.Select(selection_original, 0)
                End If
            End If
        Next
    End Sub
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Syntax Highlighting.. - by Fuzzy168 - 06-16-2012, 08:57 PM
Re: Syntax Highlighting.. - by Vinwarez - 06-18-2012, 01:49 PM
Re: Syntax Highlighting.. - by brandonio21_phpbb3_import2 - 06-18-2012, 06:00 PM
Re: Syntax Highlighting.. - by Fuzzy168 - 06-18-2012, 06:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with Syntax Highlighting? brandonio21 2 12,615 04-02-2011, 10:37 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)