1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Rep Power

    Search in InputBox VB6

    Hi All,

    I found the code
    Private Sub Command1_Click()
    Dim target_name As String
    Dim r As Integer
        target_name = InputBox("PODAJ NAZWĘ", "NAZWA", "")
        If Len(target_name) = 1 Then Exit Sub
        target_name = LCase$(target_name)
        For r = 1 To MSHFlexGrid1.Rows - 1
            If LCase$(MSHFlexGrid1.TextMatrix(r, 7)) = target_name Then
                MSHFlexGrid1.Row = r
                MSHFlexGrid1.RowSel = r
                MSHFlexGrid1.Col = 0
                MSHFlexGrid1.ColSel = MSHFlexGrid1.Cols - 1
                MSHFlexGrid1.TopRow = r
                Exit Sub
            End If
        Next r
        End Sub
    The code works fine, but the condition introduced in InputBox shows me the first line in MSHFLEXGRID selected search words and I want to see all. Exit Sub I removed, but showed last line, which satisfies the condition. Can you help me?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Rep Power
    There are a couple of ways to approach this. Assuming you are using a database to populate your FlexGrid, you could use the selection criteria to create an SQL statement to recover only the records you want in the order in which you want them. Then use that recordset to populate your FlexGrid.

    Alternately you could use a DataGrid instead of a FlexGrid. A DataGrid allows the use of a BookMark Collection. It is not as easy to work with, but has more features.

    J.A. Coutts

IMN logo majestic logo threadwatch logo seochat tools logo