total in datagridview gives back 0

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TG

    total in datagridview gives back 0

    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.R ows.Count - 1
    myTotalSum +=
    Convert.ToInt16 (DataGridView1( i, row).Value)
    Next
    DataGridView1(i , DataGridView1.R ows.Count -
    1).Value = myTotalSum.ToSt ring()
    Next


    Thank you!


    Tammy



  • TG

    #2
    Re: total in datagridview gives back 0

    any ideas?

    Comment

    • TG

      #3
      Re: total in datagridview gives back 0

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


      Comment

      Working...