0

Using flexgrid.

flexgrid row

id value

001 200
003 400
002 600
...

I want to sum the value column, sum(value) in flex grid,

Flexgrid rows are populating from the table, at last right side i want to show the total of value column in flex grid itself. How to do this.

Expected Output

id value

001 200
003 400
002 600
........

Total 1200 ' I want to show the total in flex grid itself...
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
JetJack
  • 978
  • 8
  • 26
  • 51
  • 1
    Still no need to put "need VB6 code help". That is implied by asking a question with the vb6 tag on a code/programming website. – Deanna Jun 27 '12 at 08:26
  • Can't you just sum the values as you add the rows to the grid, then add a total row at the end? – Deanna Jun 27 '12 at 08:32

1 Answers1

0
Private Sub Command1_Click()
  Dim intRow As Integer
  Dim intTotal As Integer
  intTotal = 0
  With MSFlexGrid1
    For intRow = 0 To .Rows - 2
      intTotal = intTotal + Val(.TextMatrix(intRow, 1))
    Next intRow
    .TextMatrix(3, 1) = CStr(intTotal)
  End With 'MSFlexGrid1
End Sub

Private Sub Form_Load()
  With MSFlexGrid1
    .TextMatrix(0, 0) = "001"
    .TextMatrix(1, 0) = "003"
    .TextMatrix(2, 0) = "002"
    .TextMatrix(0, 1) = "200"
    .TextMatrix(1, 1) = "400"
    .TextMatrix(2, 1) = "600"
    .TextMatrix(3, 0) = "Total"
  End With 'MSFlexGrid1
End Sub
Hrqls
  • 2,944
  • 4
  • 34
  • 54