Grid logic problem
Posted on 2004-04-20
I can't think today. I have a grid loaded with items. I have a loop that runs through each row and selectively removes what rows aren't required. Here's what I've been playing with:
For x = 0 To Grid1.Rows - 1
If Grid1.Cell(flexcpText, x, 8) = "0" Then
' x = x + 1
This uses a VSFlexgrid but a grid's a grid for these purposes. Anyways, my problem is, I've started the loop from 0 to rows-1. Lets say there's 6 rows when the loop starts. When I remove an item, Grid1.Rows is now 5, and when x reaches its upper value (6) it's an invalid cell reference beacuse the number of items was reduced. After the Removeitem, I've tried adding 'x=x+1' to force it out of the loop but for some reason I still get the same problem; 5 items (0-4) but an x value of 5 because one was removed.
Is there some way of re-assigning the upper bounds of the for loop while the loop is running? (or some other solution...)