help me with arrays... hu hu hu
write a procedure to calculate the column total and the the row total only. Use the array table below. The table is declared as mcItems (1 to 4, 1 to 5)
Code:
No of items Row total
5 7 8 3 2 25
4 2 3 8 2 19
5 1 6 0 5 17
4 6 8 9 2 29
Column Total
18 16 25 20 11
i wrote a procedure about printing the total.. but my lecturer wants to store the total value.. i haven't hav a clue!
please
Re: help me with arrays... hu hu hu
Welcome to VBForums :wave:
As this question is not related to databases, I have moved it from our Database Development forum to the Classic VB forum.
I would recommend creating two extra arrays, one for the Row totals, and one for the Column totals. You can then use loops to read the mcItems array, and store the totals in these new arrays.
Re: help me with arrays... hu hu hu
Here is a sample of how to add the totals, this does not display it on your page, you will have to do that yourself.
VB Code:
Private mcItems(1 To 4, 1 To 5) As Byte
Private Sub CalcTotals()
Dim ColTotals(1 To 5) As Long
Dim RowTotals(1 To 4) As Long
Dim i As Long, ii As Long
For i = 1 To 5
For ii = 1 To 4
ColTotals(i) = ColTotals(i) + mcItems(ii, i)
RowTotals(ii) = RowTotals(ii) + mcItems(ii, i)
Next ii
Next i
'instead of using Msgbox you can save them to a textbox or whatever you need
For i = 1 To 4
MsgBox RowTotals(i)
Next i
For i = 1 To 5
MsgBox ColTotals(i)
Next i
End Sub
Private Sub Form_Load()
'set ur array values in mcItems first
mcItems(1, 1) = 5
'...
CalcTotals
End Sub
Re: help me with arrays... hu hu hu
thanks a lot... this really help.... THANK YOU!