September 17th, 2013, 04:56 AM
Search in InputBox VB6
I found the code
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?
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
September 17th, 2013, 10:29 AM
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.