Solved

MSFlexGrid - vb6 deletion of rows

Posted on 1998-12-01
1
249 Views
Last Modified: 2012-06-27
I have used msflexgrid.clear, also a routine to back up the rows within the grid to get to row 1. I have also used
msflexgrid.row = 1, but I always seem to get blank lines, sometimes several, before I start writing within the grid again. Is there magic to get back to row 1 in order to start writing rows again.

This is the routine I have used, it clears the grid, but I get blank lines before I start adding rows again to the grid.

Private Sub cmdRouteAbandon_Click()
Dim K As Integer
On Error GoTo ErrorSection
  'clear grid
   gClrCnt = gClrCnt + 1
   MSFlexGridNewRoute.Row = gClrCnt 'last row
   For K = 1 To gClrCnt
            MSFlexGridNewRoute.Col = 0
            MSFlexGridNewRoute.Text = " "
            MSFlexGridNewRoute.Col = 1
            MSFlexGridNewRoute.Text = " "
            MSFlexGridNewRoute.Col = 2
            MSFlexGridNewRoute.Text = " "
            MSFlexGridNewRoute.Col = 3
            MSFlexGridNewRoute.Text = " "
    If gClrCnt > K Then
        MSFlexGridNewRoute.Row = MSFlexGridNewRoute.Row - 1
    End If
    Next K
    'MSFlexGridNewRoute.Rows =
    SegRteFrom = cboMasterFromZone.
    cboRouteTo.SetFocus
    gClrCnt = 0
    Exit Sub
ErrorSection:
    MsgBox "Error:" & Err & " " & Err.Description
    'will call error program from here errors.vbp
    Exit Sub
End Sub
0
Comment
Question by:MaryD
1 Comment
 
LVL 2

Accepted Solution

by:
dabellei earned 50 total points
Comment Utility
One thing i do to clear a grid is

' this will clear the grid and reset number of rows
' set the gridrows to the number you want
' it's fast and it's working
msflexgrid.rows=1

msflexgrid.rows=  number_of_rows_you_want



' if you're in a database

do while not data.eof
   ' add a row to the grid
   msflexgrid.rows=msflexgrid.rows+1
   ' position to the last row of the grid
   msflexgrid.row=msflexgrid.rows-1
   'fill in the grid as you wish
   data.movenext
loop




0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now