Results 1 to 2 of 2

Thread: How to find/search and extract FAST

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    3

    Post

    How do I find and extract strings from large strings/files (+100kB) f-a-s-t ? I've tried the RichTextBox.Find() and InStr() methods. They work fine when you search in smaller text, but when the string is big...

    Example...

    Sub TooSlow()

    Dim i As Long
    Dim j As Long

    i = RichTextBox1.Find("<a href", , , rtfNoHighlight)
    While i > -1
    j = RichTextBox1.Find("</a>", i + 7, , rtfNoHighlight)
    If j > -1 Then
    ' do stuff (a = mid(RichTextBox1,i,j) for example
    Else
    Exit Sub
    End If
    i = RichTextBox1.Find("<a href", j + 4, , rtfNoHighlight)
    Wend
    End Sub


    Repeating the sub routine ten times is three times faster than calling it once with a ten times larger string...

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    If you don't need to display file you can simply open these file and looking for string.

    Dim fileline$, searchline$

    Open "FILE.TXT" For Input As #1 ' Open file for input.
    Do While Not EOF(1) ' Loop until end of file.
    Input #1, fileline
    If Instr(fileline, searchline)>0 Then MsgBox "I'm find my string!"
    Loop
    Close #1 ' Close file.

    Best regards.

    ------------------
    smalig
    [email protected]
    smalig.tripod.com

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