vb数组中的sum列

时间:2014-10-24 18:27:49

标签: arrays vb.net sum

我在汇总多列数组中的列时遇到问题。

我有这段代码

Dim sum As Integer
Dim v As Integer
    For Each v In array
        sum = sum + v
    Next v

但是这段代码总结了整个数组。谁能告诉我如何只对一列进行总结?这是视觉工作室 - 而不是Excel!

最好的问候

顺便说一下

这是数组的填充方式

Dim array(100, 4) As Integer

For h = 1 To 5
    For j = 11 To Common.GlobalCounter + 9
        If Form1.FlowLayoutPanel1.Controls("GroupBox" & 1).Controls("labRun" & j & h).Text = "" Then
            array(j - 10, h - 1) = 0
        Else
            array(j - 10, h - 1) = Form1.FlowLayoutPanel1.Controls("GroupBox" & 1).Controls("labRun" & j & h).Text
        End If
    Next
Next

如果文本框

,则是分配的值

1 个答案:

答案 0 :(得分:0)

Dim sum As Integer = 0
Dim i As Integer = 0
Dim column As Integer = some value '0-4

For i = 0 To array.GetLength(0) - 1 'get row length
    sum += array(i, column)
Next