2012-06-27 39 views
0

使用flexgrid。如何獲取列值總計

的FlexGrid行

id value 

001 200 
003 400 
002 600 
... 

我要總結在彎曲網格值列,SUM(值),

的Flexgrid行從表填充,最後右側我想表現 Flex網格本身中的值列總數。這個怎麼做。

預期輸出

id value 

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

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

仍然沒有必要把 「需要VB6代碼幫助」。這是通過在代碼/編程網站上向vb6標籤提出問題來暗示的。 – Deanna

+0

難道你只是在將行添加到網格中時總結這些值,然後在最後添加一行? – Deanna

回答

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