Hi
Is there a way that i can a loop in my program

Dim Total1,Total2,Total3,total4,Total5,Total6,Total7 ,Total8,Total9,Total10 as integer

For I = 0 to 100

Total1= InterestRate(i, Listview1.Items(0).SubItems(1).text,Listview1.items(0).subitems(2))
Total2= InterestRate(i,Listview1.items(1).subitems(1).text,Listview1.items(1).subitems(2))

Dim Item1 as new ListviewItem(i)

Item1.Subitems.add(FormatCurrency(Total1+Total2,2)

ListView2.Items.addrange(new listviewitem() {Item1})
Next

This works because i have know how many rows have data for the calculation in listview1. I would like to somehow code it so it checks the listview1 count and then make the calculation based on how many rows.

ie 3 rows of date have been entered by the user then item1.subitems.add(formatcurrency(total1+total2+total3,2)

Many Thanks.

Can you please be clearer on the format of your listview? For example, you say you have three rows of date. Does that mean the rows after that will have different data? If all rows are the same format then please state the format of the various columns. A clearer statement (as an example) would be:

I have a listview with a variable number of rows. The first column contains a date. The next three columns contain currency amounts. For each row I want to calculate the total currency amounts and place the total in the last column.

If you can be a little clearer then I can probably help you out.

Hi

Thanks for your interest.

The row data in listview1 will allways have the same data.
The first column will be the count. (i)
The Second and third Column will be a number.
There is a function that i have called Interest rate that just calculates the second and third column data as a percentage.

Yes i would like to calculate each row total in listview2 with a loop so that i have the exact amount of totals matching the rows.

Ie if rowcount is 1 then total(1)
if rowcount is 10 the total(10) which would mean total1+total2+total3.....total10 .
The above code actually works but only if i have data in two rows.

Best Regards,

Mikey

Not quite there yet. Column 1 is "the count". The count of what?

The Second and third Column will be a number.
There is a function that i have called Interest rate that just calculates the second and third column data as a percentage.

Apparently all of the columns contain "a number". Are the original numbers in columns 2 and 3 replaced by percentages? What are you calculating the totals of? If column 1 contains a count and columns 2 and 3 contain a percentage then a total of all three makes no sense. What happened to the dates you mentioned in the OP? Please reread my original response about clarity.

Yes the listview1 is a data entry listview. it wiil only contain two columns with numbers. My main problem is trying sum up the values the listview1 values into the listview2 which i can for a chart from. Basically i would like to have listview1 that the user can input two values. From there listview2 will generate nnumbers from the count say 1 to 100 that will be followed by my function. ie interestrate(count, data1 from listview1,data2 from listview1)

once i have the listview2 data then i can form a chart. I have achieved this successfully with my code from the first post but is only limited to a certain amount of rows which need to be known first.

This article has been dead for over six months. Start a new discussion instead.