Help with sum or rows using arrays in VB

  • Thread starter Thread starter rburdette
  • Start date Start date
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
 
i believe that vb.net has matrix functions you just need to find the right
namespace check the msdn

WStoreyII
 
The .NET Framework has no built in support for matix manipulation other than
a 3 x 3 matrix in the System.Drawing.Drawing2D namespace which is intended
for graphical operations.

One potential solution is a the MapPack DLL from Lutz Roeder's. You may
download a free copy of MapPack at:

http://www.aisto.com/roeder/dotnet/
 
Back
Top