Private Sub Command1_Click()
Dim target_name As String
Dim r As Integer    ' Get the name.
    target_name = InputBox("Name", "Name", "")
    If Len(target_name) = 0 Then Exit Sub    ' Search for the name, skipping the column heading row.
    target_name = LCase$(target_name)
    For r = 1 To MSFlexGrid1.Rows - 1
        If LCase$(MSFlexGrid1.TextMatrix(r, 0)) = target_name Then
            ' We found the target. Select this row.
            MSFlexGrid1.Row = r
            MSFlexGrid1.RowSel = r
            MSFlexGrid1.Col = 0
            MSFlexGrid1.ColSel = MSFlexGrid1.Cols - 1            ' Make the row visible.
            MSFlexGrid1.TopRow = r
            Exit Sub
        End If
    Next r    ' We didn't find it.
    Beep

解决方案 »

  1.   

    我用
    For i = 0 To rs.RecordCount - 1
         For j = 0 To rs.Fields.Count - 1
               editclass.Row = i
               editclass.Col = j          
                 If Trim(editclass.Text) = "a" Then
                    editclass.Text = ""
                 Else
                ......
                 If rs.EOF Then MsgBox "已搜索指定的区域! ": Exit Sub
                 End If
        Next j
     Next i
     为什么在editclass.Row = i错误提示"行号无效"
             此时i=8,editclass.row=1
          为什么会这样呢?