Results 1 to 2 of 2

Thread: [RESOLVED] MSFlexGrid Search is easy, Next match is needed

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    186

    Resolved [RESOLVED] MSFlexGrid Search is easy, Next match is needed

    Below is what I use to search MSFlexGrid for a string using Regular Expressions. Dont forget to add a reference to Microsoft VBScript Regular Expressions 5.5 to your project.

    on form:
    VB Code:
    1. Private Sub Command1_Click()
    2. 'search button
    3. On Error Resume Next
    4. If Text1.Text <> "" Then
    5.     Dim myRow
    6.     For myRow = 0 To MSFlexGrid1.rows
    7.         If RegExTF(MSFlexGrid1.TextMatrix(myRow, 0), Text1.Text) = True Then
    8.             MSFlexGrid1.TopRow = myRow
    9.             MSFlexGrid1.Row = myRow
    10.             Exit Sub
    11.         End If
    12.     Next myRow
    13. End If
    14. End Sub

    in module:
    VB Code:
    1. Function RegExTF(SearchThis As String, Search4This As String)
    2.     Dim ssnvar, re
    3.     ssnvar = SearchThis
    4.     Set re = New RegExp
    5.     re.Pattern = Search4This
    6.     re.Global = True
    7.     re.IgnoreCase = True
    8.     If re.Test(ssnvar) = True Then RegExTF = True Else RegExTF = False
    9. End Function

    What I need is to go to the Next match on Command1_Click if more than one match was found. Something like "Find Next" in most text editors. Is it possible?

    Thank you in advance!
    Last edited by foxter; Apr 29th, 2006 at 03:14 PM.

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