Results 1 to 18 of 18

Thread: [RESOLVED] Search engine speed

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378

    Resolved [RESOLVED] Search engine speed

    Hello,

    Anybody know of the fastest search engine in VB?

    I loaded the whole kjv Bible into a rtf box and it took me 37 seconds to fine the word "day."

    Code:
    Private Function WordCount(strLine As String, strWord As String) As Long
       WordCount = (Len(strLine) - Len(Replace(strLine, strWord, ""))) / Len(strWord)
    
    End Function
    
    Private Sub cmdFindNext_Click()
     Dim intIdx As Long
     Dim CountLeft As Integer
     Dim response As String
     Dim strtext As String
     Dim NumLoop As Integer
    
     FoundLabel.Visible = True
    
     strtext = RTFText1.Text
    
     RTFText1.SetFocus
    
     If txtSearch.Text = "" Then
       COUNTED = 0
       Exit Sub
     End If     
     
     COUNTED = COUNTED + 1
     CountLeft = WordCount(strtext, txtSearch.Text) - COUNTED
    
     NumLoop = NumLoop + 1
     FoundLabel.Caption = " Hit #" & COUNTED & " of " & WordCount(strtext, txtSearch.Text) & ", there are "  & CountLeft & " Left"
    
     RTFText1.Find txtSearch, RTFText1.SelStart + 1, Len(RTFText1.TextRTF)
    
     If NumLoop = 2 Then
       FoundLabel.Caption = " Hit #" & COUNTED - 1 & " of " & WordCount(strtext, txtSearch.Text)
       Beep
       COUNTED = 0
       Exit Sub
     End If
        POS = Form1a.RTFText1.SelStart
        POS = InStr(POS + 1, Form1a.RTFText1.Text, txtSearch.Text)
             
      If POS = 0 Then
                 
       response = MsgBox("your search for ~ " & txtSearch & " ~ ... was found a total of " & COUNTED - 1 & " time(s). ...  Do you want to start from the beginning?", vbYesNo)
       COUNTED = 0
       FoundLabel.Caption = " Hit #" & COUNTED & " of " & WordCount(strtext, txtSearch.Text)
    
               If response = vbNo Then
                   Exit Sub
               Else
    
                   RTFText1.Find txtSearch, RTFText1.SelStart + 1, Len(RTFText1.TextRTF)
             
                   Form1a.RTFText1.SelStart = POS 'GOES TO THE TOP
               End If
      End If
    
    If OptVar1 = True Then
       Exit Sub
    End If
    
    RTFText1.SelColor = vbRed
    RTFText1.SetFocus
    SendKeys "{down 20}"
    
    If SearchBoldVar = True Then
       RTFText1.SelBold = Not RTFText1.SelBold
    End If
    
    If SearchItalicVar = True Then
       RTFText1.SelItalic = Not RTFText1.SelItalic
    End If
    
    If SearchUnderlineVar = True Then
       RTFText1.SelUnderline = Not RTFText1.SelUnderline
    End If
    
    If SearchRegularVar = True Then
       SearchItalicVar = False
       SearchBoldVar = False
       SearchUnderlineVar = False
    End If
    
    Exit Sub
     
    End Sub
    Last edited by GARY MICHAEL; Mar 8th, 2010 at 05:17 PM.
    Thanks,
    GARY

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