Results 1 to 4 of 4

Thread: filter expression for search string

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    filter expression for search string

    whats a good filter expression for one up to 3 keywords.

    if one keyword, it will be
    NAME = '*keyword1*'

    if 2 keyword, it will be
    NAME = '*keyword1*' OR NAME = '*keyword2*'

    if 3 keyword, it will be
    NAME = '*keyword1*' OR NAME = '*keyword2*' OR NAME = '*keyword3*'

    problem is how do i know if its 1 or 2 or 3 keyword entered in a search string

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    106

    Re: filter expression for search string

    any experts knows this?

  3. #3
    Lively Member
    Join Date
    Jun 2004
    Posts
    99

    Re: filter expression for search string

    This is definately not an expert answer hehe. But this may help get you on track.

    Code:
    Private Function GetFilterString(ByVal SearchString as String) As String
      Dim strSearchWords as String()
      Dim Filter as String
    
      strSearchWords = SearchString.Split(New [Char]() {" "})
      For i as Integer = 0 to strSearchWords.Length() - 1
         If Filter <> "" Then
            Filter &= " OR "
         End If
    
         Filter &= "NAME = '*" & strSearchWords(i) & "*'"
      Next
    
      Return Filter
    End Function

  4. #4
    Lively Member
    Join Date
    Jun 2004
    Posts
    99

    Re: filter expression for search string

    If you are specifically looking for the number, then just return the .length in the code that I posted.

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