silvanag
2016-02-21T22:39:33Z
Hi all.

I need help to manage .ROWCOUNT function

I have to create a list from a file with many records and I think the fastest way is to use the FILLFROMRS function.
After loading my recordset I need to create "child" lines, only under certain conditions.

Then i read with my grid with a for next cycle, using .ROWCOUNT as a parameter, in this simple way:

for ix = 1 to igrid.rowcont
    if okmytest  then
	.AddRow vRowBefore:=ix, vRowParent:=ix
    end if
next


My problem is the rowcount value that does not dynamically update with the addition of child rows.
So (p.e.) if I start with 20 lines (rowcount = 20) and I add 7 child rows, my for-next cycle stops at the twentieth and NOT reads the last 7 rows "father" that should read, because the 7 additions are actually "child"

I also tried using a variable for the for-next loop, but I can not read all lines "father"

Can someone help me? sorry my bad English
tnx a lot.
Igor/10Tec
2016-02-22T08:00:29Z
This is a question about VB6 but not iGrid.

The end expression for a For..Next loop is evaluated only once when VB starts to execute this loop. In your example, VB6 will use the end value of 20 in every iteration.
silvanag
2016-02-22T08:13:53Z
Originally Posted by: Igor/10Tec 

This is a question about VB6 but not iGrid.

The end expression for a For..Next loop is evaluated only once when VB starts to execute this loop. In your example, VB6 will use the end value of 20 in every iteration.



Ok, Tnx. Any suggestions?
silvanag
2016-02-23T07:53:23Z
Originally Posted by: Igor/10Tec 

This is a question about VB6 but not iGrid.

The end expression for a For..Next loop is evaluated only once when VB starts to execute this loop. In your example, VB6 will use the end value of 20 in every iteration.



Hi.
There is a way to test the "igrid row valid" (row father) to make a loop while i'm increase the row number with child?
Igor/10Tec
2016-02-23T08:21:11Z
You can use the Do While..Loop loop for that. And don't forget to increase your loop counter by 1 when you add a new row in the loop.
silvanag
2016-02-23T09:14:01Z
Originally Posted by: Igor/10Tec 

You can use the Do While..Loop loop for that. And don't forget to increase your loop counter by 1 when you add a new row in the loop.



OK. What is the test for the loop?
Igor/10Tec
2016-02-23T11:32:38Z
In my understanding, it should be something like this:


ix = 1
Do While ix <= iGrid1.RowCount
    If okmytest  Then
        iGrid1.AddRow vRowParent:=ix
        ix = ix + 1
    End If
    ix = ix + 1
Loop
silvanag
2016-02-24T08:49:59Z
Originally Posted by: Igor/10Tec 

In my understanding, it should be something like this:


ix = 1
Do While ix <= iGrid1.RowCount
    If okmytest  Then
        iGrid1.AddRow vRowParent:=ix
        ix = ix + 1
    End If
    ix = ix + 1
Loop



PERFECT!! it works!! very very very tnx! Grazie Mille! :-)))