Search for matching string

Private Function SearchForBugs(BugF As BugFactory, _
        DescriptionSubString As String) _
        As List

' Search for Bugs that match a string   
    
    Dim BugSearchF As ISearchableFactory
    Dim bList As List
    Dim oneBug As Bug
    Dim i, limit
    
On Error GoTo FUNC_ERR
 
' Cast the BugFactory to get an ISearchableFactory reference.
    
    Set BugSearchF = BugF

' Get the list of matches and output.
    Dim SearchOpts As SearchOptions
    Set SearchOpts = BugSearchF.CreateSearchOptions
    Set bList = BugSearchF.Search(DescriptionSubString, SearchOpts)
    limit = 30
    If (bList.Count < limit) Then limit = bList.Count
    Debug.Print "Bugs found by Search for: " & DescriptionSubString
    For i = 1 To limit
        Set oneBug = bList.Item(i)
        Debug.Print oneBug.ID & " - " & oneBug.Summary & " - " & oneBug.Field("BG_DESCRIPTION")
    Next i
  
    Set SearchForBugs = bList
 
Exit Function
FUNC_ERR:
    Set SearchForBugs = Nothing
End Function