473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Q: Index for a row

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

Nov 20 '05 #1
8 1032
You can use the for statement:

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


"Geoff Jones" wrote:
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

Nov 20 '05 #2
You can look at the RowNumber property for a cell in the row.

index = row.Item(0).RowNumber

HTH
--
David Williams, VB.NET MVP
"Geoff Jones" wrote:
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

Nov 20 '05 #3
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" <Al******@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
You can use the for statement:

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


"Geoff Jones" wrote:
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

Nov 20 '05 #4
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" <Al******@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
You can use the for statement:

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


"Geoff Jones" wrote:
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


Nov 20 '05 #5
Hi Cor

Merely being inquisitive :)

Geoff

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
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" <Al******@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
You can use the for statement:

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


"Geoff Jones" wrote:

> 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
>
>
>
>



Nov 20 '05 #6
Hi David,

I can not find that, do you have a link on MSDN for that one?

Cor
You can look at the RowNumber property for a cell in the row.

index = row.Item(0).RowNumber

HTH
--
David Williams, VB.NET MVP
"Geoff Jones" wrote:
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

Nov 20 '05 #7
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
"David Williams" <Da***********@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com...
You can look at the RowNumber property for a cell in the row.

index = row.Item(0).RowNumber

HTH
--
David Williams, VB.NET MVP
"Geoff Jones" wrote:
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

Nov 20 '05 #8
I think David was using a member of a DataGrid; which wasn't the case I was
dealing with. Good try though!

Geoff

"Samuel L Matzen" <sm*****@slm.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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
"David Williams" <Da***********@discussions.microsoft.com> wrote in message news:BD**********************************@microsof t.com...
You can look at the RowNumber property for a cell in the row.

index = row.Item(0).RowNumber

HTH
--
David Williams, VB.NET MVP
"Geoff Jones" wrote:
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


Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jofio | last post by:
Hello, I am a newbie in PHP and I am enthusiastically trying out things. I've just replaced my index.html ( file with index.php
9
by: kosh | last post by:
I was wondering if there is or there could be some way to pass a generator an optional starting index so that if it supported that slicing could be made more efficient. Right now if you do use a...
2
by: skura | last post by:
I am trying to understand how the data in sql server is stored and also regarding fill factor and page splitting. 1) My first question what is the difference between Index pages and Data pages....
6
by: Anita | last post by:
I have just tested 3 queries using QA. The complete test information : ------ CREATE TABLE agls1 ( fyear char(4) NULL , fprefix char(3) NULL , fvcno char(20) NULL , fdate datetime NULL ,...
8
by: Andr? Queiroz | last post by:
Hi, I have a table with 10M records and col A has a index created on it. The data on that table has the same value for col A on all 10M records. After that I insert diferent values for that column...
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
4
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
2
by: bobby_b_ | last post by:
I have a table where fields 1 and 2 make up the primary key. Because of this, I have a unique composite index on fields 1 and 2 (as required by DB2). Now my question is: Fields 1 and 2 are also...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
8
by: shira | last post by:
I have done a fair bit of searching, but haven't yet been able to find an explanation as to why one would set "ignore nulls" to "yes" when creating an index. I understand what it does (I think),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.