Search on flexgrid vb6

hi friends,
i was adding a search option to my vb6 project form on flexgrid object.. i wrote a set of code which works fine to find fields which is not matching and removing from the flexgrid (ultimately the rest will be the search answer)..but the issue what i am facing right now is i need to find all the partial matching fields,l..eg :if a person searching for the name john all the names starts or end with john need to be displayed.. i hope you understood my issue..

the code i written is given below

 Dim target_name As String
  target_name = InputBox("Enter The Keyword you wish to Search", "Search")
  If Len(target_name) = 0 Then Exit Sub
  target_name = LCase$(target_name)

Dim r As Integer
Dim c As Integer
Dim boo As Boolean

  For r = FlexGrid.Rows - 1 To 1 Step -1
    boo = False
         For c = 1 To FlexGrid.Cols - 1
         If LCase(FlexGrid.TextMatrix(r, c)) = target_name Then
         boo = True
         Exit For
       End If
       Next c
   

    If boo = False Then FlexGrid.RemoveItem (r)
  Next r
   
IntelopsAsked:
Who is Participating?
 
danaseamanCommented:
Replace:
If LCase(FlexGrid.TextMatrix(r, c)) = target_name Then

With:
If InStr(1, FlexGrid.TextMatrix(r, c), target_name, vbTextCompare) Then
0
 
IntelopsAuthor Commented:
the above mentioned issue was resolved through the method specified by mr.danaseaman.. but now i have an issue with the same code

if my fixed rows on the flexgrid is enabled its giving an error that as "Cannot remove last non-fixed row" while the search didnt return any answer.. can anybody help me on this..???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.