BP Forums
Problem with Syntax Highlighting? - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Problem with Syntax Highlighting? (/showthread.php?tid=336)



Problem with Syntax Highlighting? - brandonio21 - 04-02-2011

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?


Re: Problem with Syntax Highlighting? - xolara - 04-02-2011

i think it would be better if we could have the project file <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile -->


Re: Problem with Syntax Highlighting? - brandonio21 - 04-02-2011

Haha, alright. This should do it then,
[attachment=0]<!-- ia0 -->HTML-IDEx.zip<!-- ia0 -->[/attachment]