total in datagridview gives back 0

T

TG

Hi!

I have a datagridview and I want to sum one of the columns. (column 5)

When I run the following it gives me 0 instead of 10106 which is the
total of those rows.

Any ideas as to what I am doing wrong?

For i As Integer = 5 To 5
' loop through columns which require
calculating sum
Dim myTotalSum As Integer
For row As Integer = 10 To
DataGridView1.Rows.Count - 1
myTotalSum +=
Convert.ToInt16(DataGridView1(i, row).Value)
Next
DataGridView1(i, DataGridView1.Rows.Count -
1).Value = myTotalSum.ToString()
Next


Thank you!


Tammy
 
T

TG

nevermind i fixed it myself.

I was starting at the wrong point

For row As Integer = 10 To


is supposed to be


For row As Integer = 0 To


Thanks to myself for the help :)))))))
 

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

Top