row.count

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

I have a for loop, which runs through all the rows in a listview.
however, i added some new rows within the for loop..

so my problems now is that it doesn't loop thru the whole table, but instead
only upto the orginal number of rows...... How should i update the row count
so it can loop thru all the rows included the newly added ones??

Dim k As Integer
For k = 0 To MyListView.Items.Count - 1
....
add some rows...
....
changes some rows...
....
Next

Thanks.
 
Jon,
I would use a Do loop instead of a For loop, and manually increment the
index.

Something like (untested):

Dim k As Integer = 0
Do Until k >= MyListView.Items.Count
...
add some rows...
...
changes some rows...
...
k += 1
Loop

Hope this helps
Jay
 
Thanks,

but will the MyListView.Items.Count update itself every loop?
 
Jon,

This is a real dangerous routine in my opinion.

Even a do loop with a count can give in my opinion unpredictable results.

I think that I would do it like this (writen here so watch typos ore other
errors)

\\\
Do Until "condition to stop is true"
Dim k As Integer
For k = 0 To MyListView.Items.Count - 1
...
add some rows... exit For
...
changes some rows... exit For
...
Next
Loop
///

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top