R
rburdette
I need to do a sum of rows and sum of columns in Visual Basic. Is there
another way to do it other than the one I have below?
5 7 3 9 12
4 8 9 13 4
0 -`1 -7 13 8
4 4 4 4 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
array(0, 0) = 5
array(0, 1) = 7
etc........
Private Sub MenuPerformAction_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MenuPerformAction.Click
If MenuSumRows.Checked = True Then
Dim result(3)
For rows = 0 To 3
total = 0
For columns = 0 To 4
total = total + array(rows, columns)
Next
result(rows) = total
Next
response = MsgBox("Row 1: " & result(0) & ControlChars.NewLine
& _
"Row 2: " & result(1) & ControlChars.NewLine & _
"Row 3: " & result(2) & ControlChars.NewLine & _
"Row 4: " & result(3) & ControlChars.NewLine &
ControlChars.NewLine & _
"Continue?", MsgBoxStyle.YesNo, "Sum of Rows")
If response = MsgBoxResult.No Then
End
another way to do it other than the one I have below?
5 7 3 9 12
4 8 9 13 4
0 -`1 -7 13 8
4 4 4 4 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
array(0, 0) = 5
array(0, 1) = 7
etc........
Private Sub MenuPerformAction_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MenuPerformAction.Click
If MenuSumRows.Checked = True Then
Dim result(3)
For rows = 0 To 3
total = 0
For columns = 0 To 4
total = total + array(rows, columns)
Next
result(rows) = total
Next
response = MsgBox("Row 1: " & result(0) & ControlChars.NewLine
& _
"Row 2: " & result(1) & ControlChars.NewLine & _
"Row 3: " & result(2) & ControlChars.NewLine & _
"Row 4: " & result(3) & ControlChars.NewLine &
ControlChars.NewLine & _
"Continue?", MsgBoxStyle.YesNo, "Sum of Rows")
If response = MsgBoxResult.No Then
End