Results 1 to 10 of 10

Thread: Find text in RTB is very slow ?[Resolved]

Threaded View

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Find text in RTB is very slow ?[Resolved]

    This method works but it's damn slow . It takes about 1 minute to colorize some keywords . I feel like there is a way to improve it and speed it up . Anyone has a solution or alternative method ?

    VB Code:
    1. Public Sub FindHighlight(ByVal Keywords As ArrayList, ByVal HighlightColor As Color)
    2.         Me.SuspendLayout()
    3.         Dim StartLooking As Integer = 0
    4.         Dim FoundAt As Integer
    5.         Dim SearchLength As Integer        
    6.  
    7.         For Each keyword As String In Keywords
    8.  
    9.             SearchLength = keyword.Length
    10.             Application.DoEvents()
    11.             Do
    12.                 FoundAt = Me.RichTextBox1.Find(keyword, StartLooking, RichTextBoxFinds.WholeWord)
    13.                 If FoundAt > -1 Then Me.RichTextBox1.SelectionColor = HighlightColor
    14.                 StartLooking = StartLooking + SearchLength
    15.             Loop While FoundAt > -1
    16.             SearchLength = 0
    17.             FoundAt = 0
    18.             StartLooking = 0
    19.         Next
    20.  
    21.         Me.ResumeLayout()
    22.     End Sub

    btw , I'll not go with threading now .It's my last option , I think


    Thanks
    Last edited by Pirate; May 23rd, 2004 at 10:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width