Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Syntax Highlighting?
#1
Hey guys. Here's a question for ya guys...
Code:
Dim listbox1 As New ListBox
    listbox1.Items.Add("<br/>")
    Dim int As Integer = 0
    Dim line As String = RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart)
    For Each item In listbox1.Items
      If RichTextBox1.Lines(line).Contains(item) Then
        Dim instance As Integer = RichTextBox1.Find(item, RichTextBox1.SelectionStart - CInt(item.ToString.Length), RichTextBox1.SelectionStart)
        If instance > 0 Then
          RichTextBox1.SelectionStart = RichTextBox1.SelectionStart - CInt(item.ToString.Length)
          RichTextBox1.SelectionLength = item.ToString.Length
          RichTextBox1.SelectionColor = Color.Blue
        End If
      End If

    Next
    RichTextBox1.SelectionStart = ss
    RichTextBox1.SelectionLength = sl
    RichTextBox1.SelectionColor = Color.Black
My coding selects an item from the list box and tries to color the words in the currently selected line, however, it often colors characters that come after the instance. Why is this happening?
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Problem with Syntax Highlighting? - by brandonio21_phpbb3_import2 - 04-02-2011, 03:58 PM
Re: Problem with Syntax Highlighting? - by xolara - 04-02-2011, 08:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I am getting problem with brandonio's registration form... mnxford 1 9,172 03-27-2013, 10:55 AM
Last Post: mnxford
  i am getting a problem with brandonio's login form mnxford 1 9,100 03-27-2013, 10:55 AM
Last Post: mnxford
  Syntax Highlighting.. Fuzzy168 3 13,256 06-18-2012, 06:28 PM
Last Post: Fuzzy168

Forum Jump:


Users browsing this thread: 1 Guest(s)