none
RichText box selection - How do you highlight mis match element? RRS feed

  • Question

  • Hi,

    I have two array, both are different length. The first index of the array is matched against the entire indexes of the second array to see if the first array contains inside the second array. If it not it will highlight onto the rich text box accordingly. However how can i use the RichTextBox3.Select(     )  to dynamically highlight those array? Thanks!

            Dim status As Boolean
            For i As Integer = 0 To occuranceToArray.GetUpperBound(0)
                For j As Integer = 0 To occurance2toArray.GetUpperBound(0)
                    If Not Occurance(i).Equals(Occurance2(j)) Then
                        status = False
                        RichTextBox3.Select(         )   --> Require inputs
                        RichTextBox3.SelectionBackColor = Color.Yellow
                    End If
                Next j
            Next i

    Regards

    Eric

    Thursday, August 2, 2012 2:58 AM

Answers

  • Hi Eric,

    Welcome to the MSDN Forum.

    How do you display the two array in richtextbox?

    Which array do you want to highlight?

    Now, I assume you has display the first array in RichTextBox3, and you want to highlight some elements in the first array:

            Dim status As Boolean
            Dim StartIndex as Integer = 0
            'I assume you have use the same length to display every array element in rich textbox.
            Dim LengthOfArraylength as Integer = 10
    
            For i As Integer = 0 To occuranceToArray.GetUpperBound(0)
                StartIndex  = i * LengthOfArraylength 
                For j As Integer = 0 To occurance2toArray.GetUpperBound(0)
                    If Not Occurance(i).Equals(Occurance2(j)) Then
                        status = False
                        RichTextBox3.Select(StartIndex,  StartIndex +  LengthOfArraylength      )   
                        RichTextBox3.SelectionBackColor = Color.Yellow
                    End If
                Next j
            Next i

    I hope this will  be helpful.

    If I have misunderstood anything, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 3, 2012 6:55 AM
    Moderator