Hello,
I have imported some numerical values into a 2x2 array with dimensions (n-1) rows and 5 columns, where n is an integer > 2. What I am trying to do is multiply all elements from two columns of the array, say column 4 and column 2 and sum the result. My code works, but (naturally you may think...) the result is double (x2) the expected result. Is there a way to present the calculation in a more comprehensive manner instead of taking the calculated result and divide it by two?
Thank you in advance for your assistance.
I have imported some numerical values into a 2x2 array with dimensions (n-1) rows and 5 columns, where n is an integer > 2. What I am trying to do is multiply all elements from two columns of the array, say column 4 and column 2 and sum the result. My code works, but (naturally you may think...) the result is double (x2) the expected result. Is there a way to present the calculation in a more comprehensive manner instead of taking the calculated result and divide it by two?
Code:
Dim sum As Double
Dim result As Double
For Frow = 0 To CInt(n) - 1
For Fcol = 4 To 4
For yirow = 0 To CInt(n) - 1
For yicol = 2 To 2
sum += Array(Frow, Fcol) * Array(yirow, yicol)
Next
Next
Next
Next
result = sum
MsgBox("Test multiplication results " & result, MsgBoxStyle.Information, "test")
End Sub
Thank you in advance for your assistance.