Q: Index for a row

  • Thread starter Thread starter Geoff Jones
  • Start date Start date
G

Geoff Jones

Hi

Can anybody help me with the following question?

Suppose I have the following code, where myTable is already defined
elsewhere:

For Each row In myTable.Rows
' Get an index for the row
Next

Within the loop, I'd like to be able to get hold of the zero based index for
the row being used. I know that I could simply add a variable before the
loop and then increment it within the loop, but I think there is an inbuilt
function to do it e.g. row.GetIndex(), or whatever.

Can anybody help?

Geoff
 
You can use the for statement:

For i as intgeger = 0 to myTable.items.count - 1
' - represent the index of each row
' [myTable.items.item(i)] - represent the item for each row (index)
Next i
 
You can look at the RowNumber property for a cell in the row.

index = row.Item(0).RowNumber

HTH
 
Thanks Alex

However, it isn't possible to do using For Each then? That is, is there no
way of working out the index (using inbuilt members) of the row being
process in the loop?

Geoff

Alex Levi said:
You can use the for statement:

For i as intgeger = 0 to myTable.items.count - 1
' - represent the index of each row
' [myTable.items.item(i)] - represent the item for each row (index)
Next i




Geoff Jones said:
Hi

Can anybody help me with the following question?

Suppose I have the following code, where myTable is already defined
elsewhere:

For Each row In myTable.Rows
' Get an index for the row
Next

Within the loop, I'd like to be able to get hold of the zero based index for
the row being used. I know that I could simply add a variable before the
loop and then increment it within the loop, but I think there is an inbuilt
function to do it e.g. row.GetIndex(), or whatever.

Can anybody help?

Geoff
 
Hi Geoff,

You make me curious, why would you want to use it and what is than the
benefit of that?
(That for index method very effective in my opinion)

Cor
Thanks Alex

However, it isn't possible to do using For Each then? That is, is there no
way of working out the index (using inbuilt members) of the row being
process in the loop?

Geoff

Alex Levi said:
You can use the for statement:

For i as intgeger = 0 to myTable.items.count - 1
' - represent the index of each row
' [myTable.items.item(i)] - represent the item for each row (index)
Next i




Geoff Jones said:
Hi

Can anybody help me with the following question?

Suppose I have the following code, where myTable is already defined
elsewhere:

For Each row In myTable.Rows
' Get an index for the row
Next

Within the loop, I'd like to be able to get hold of the zero based
index
 
Hi Cor

Merely being inquisitive :)

Geoff

Cor Ligthert said:
Hi Geoff,

You make me curious, why would you want to use it and what is than the
benefit of that?
(That for index method very effective in my opinion)

Cor
Thanks Alex

However, it isn't possible to do using For Each then? That is, is there no
way of working out the index (using inbuilt members) of the row being
process in the loop?

Geoff

Alex Levi said:
You can use the for statement:

For i as intgeger = 0 to myTable.items.count - 1
' - represent the index of each row
' [myTable.items.item(i)] - represent the item for each row (index)
Next i




:

Hi

Can anybody help me with the following question?

Suppose I have the following code, where myTable is already defined
elsewhere:

For Each row In myTable.Rows
' Get an index for the row
Next

Within the loop, I'd like to be able to get hold of the zero based
index
for
the row being used. I know that I could simply add a variable before the
loop and then increment it within the loop, but I think there is an inbuilt
function to do it e.g. row.GetIndex(), or whatever.

Can anybody help?

Geoff

 
David,

I can't seem to get your solution to work. Can you point me to some
documentation on the RowNumber method of the Item object of a row?

-Sam Matzen
 
I think David was using a member of a DataGrid; which wasn't the case I was
dealing with. Good try though!

Geoff
 
Back
Top