0

使用弹性网格。

弹性网格行

id value

001 200
003 400
002 600
...

我想对 flex 网格中的 value 列 sum(value) 求和,

Flexgrid 行从表中填充,最后右侧我想在 flex 网格本身中显示值列的总和。这个怎么做。

预期产出

id value

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

Total 1200 ' I want to show the total in flex grid itself...
4

1 回答 1

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
于 2012-11-07T13:40:12.090 回答