i have some code i am working on andit keeps throwing an expression expected error. this code is designed to cheeck a RichTextBox form and highlight text, specified by a dictionary.

 Dim location As UInteger = 0
    Dim dict As Dictionary(Of String, ULong) = getWords(rText1)
    Dim wcount As Integer = 0
    For i As Long = 0 To dict.Count
        For j As Integer = 0 To args.Length
            If dict.ContainsKey(args(j)) Then
                For Each args(j) In dict.Keys
                    Dim count As ULong = dict.Values.ElementAt(wcount)
                    Dim colorSpace = count - args(j).Length
                    rText1.Select(colorSpace, count)
                    rText1.SelectionColor = Color.DarkBlue
                Next() 'error here
            End If
        Next
        For j As Integer = 0 To arithimic.Length
            If dict.ContainsKey(arithimic(j)) Then
                For Each arithimic(j) In dict.Keys
                    Dim count As ULong = dict.Values.ElementAt(wcount)
                    Dim colorSpace = count - arithimic(j).Length
                    rText1.Select(colorSpace, count)
                    rText1.SelectionColor = Color.OrangeRed
                Next() 'error here
            End If
        Next
        For j As Integer = 0 To logical.Length
            If dict.ContainsKey(logical(j)) Then
                For Each logical(j) In dict.Keys
                    Dim count As ULong = dict.Values.ElementAt(wcount)
                    Dim colorSpace = count - logical(j).Length
                    rText1.Select(colorSpace, count)
                    rText1.SelectionColor = Color.LightGreen
                Next() 'error here
            End If
        Next
    Next
    Dim index As Integer = rText1.Find(comment) 'this is not a for loop because it  only looks for one char
    If index <> -1 Then
        Dim lineindex As Integer = rText1.GetLineFromCharIndex(index)
        Dim first As Integer = rText1.GetFirstCharIndexFromLine(lineindex)
        Dim last As Integer = rText1.GetFirstCharIndexFromLine(lineindex + 1)
        If last = -1 Then last = rText1.TextLength
        rText1.Select(first, last - first)
        rText1.SelectionBackColor = Color.DarkGreen
    End If
End Function

any ideas?

This article has been dead for over six months. Start a new discussion instead.