使用flexgrid。
flexgrid行
id value
001 200
003 400
002 600
...
我想在弹性网格中总结值列,sum(value),
Flexgrid行从表中填充,在最后右侧我要显示 弹性网格本身的总值列。怎么做。
预期产出
id value
001 200
003 400
002 600
........
Total 1200 ' I want to show the total in flex grid itself...
答案 0 :(得分: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