OLE Automation SearchForEx Example


SearchForEx Example

 Dim searchResults As Object
 Dim search2 As Object
 Dim criteria As Object
 Set criteria = CreateObject("Wilbur.SearchCriteria")
 criteria.FileName = "*.txt"

 ‘ get the list of files with extension *.txt
 ' containing the phrase entered
 ‘ in the Text1 field 
 Set searchResults = _
        wilbur.SearchForEx(Text1.Text, criteria)

 ‘ Extract the names from the list and use them
 ' to fill a list box
 Dim bResult As Boolean
 Dim nCount As Integer
 nCount = 0
 bResult = searchResults.setToStart
 ' get number of results
Dim nTotal As Integer nTotal = searchResults.getCount While bResult
Dim lastMod As Date

' check to see if this result matches any proximity requirements
If searchResults.isNearOK Then
  lastMod = searchResults.getModifiedDate
  rank = searchResults.getRank
  List1.AddItem searchResults.getPath + _
  Chr(9) + Str(rank) + Chr(9) + Format(lastMod)
End If


nCount = nCount + 1
Status = "Checking near " & nCount & " of " & nTotal
DoEvents
bResult = searchResults.setToNext
 Wend

This will search the index and place matching files in the searchResults object. This list is then looped through and the path names, modified dates and search rank of the files which meet any proximity requirement are placed in the list box. A status line is updated with a file count.


Copyright © 1999 RedTree Development Inc. All rights reserved.
Information in this document is subject to change without notice.
Other products and companies referred to herein are trademarks or registered trademarks of their respective companies or mark holders.