Hi All

if anyone could help me that would be great!

currently i have an array which enables a user to input:
Student Name
Maths Mark
English Mark
Science Mark

Array: StudentArray(25,3)

i have this array output the data to a listview box.

Column 1: Student Name
Column 2: Maths Mark
Column 3: English Mark
Column 4: Science Mark

i would like the averages to outputed to labels.

lblMathsAverage
lblEnglishAverage
lblScienceAverage

would i use a loop to add column's 1, 2 & 3?

any help would be much appreciated! i have had a right pain tryin to get this sorted.

thanks
gary

I would average from the array. Having to go through the listview to get the values adds additional coding that just slows down the process. Also remember that since they are averages, divide by the number of students :)

Comments
helpful info.

See if this helps to loop through the 2D Array.

Dim iMathsAverage As Integer = 0, iEnglishAverage As Integer = 0, iScienceAverage As Integer = 0
        For i As Integer = 0 To StudentArray.GetLength(0) - 1 '// loop thru all Arrays.
            '// add values.
            iMathsAverage += CInt(StudentArray(i, 1))
            iEnglishAverage += CInt(StudentArray(i, 2))
            iScienceAverage += CInt(StudentArray(i, 3))
        Next
        '// Result.
        MsgBox("Math: " & iMathsAverage & vbNewLine & "English: " & iEnglishAverage & vbNewLine & "Science: " & iScienceAverage)

Edited 5 Years Ago by codeorder: n/a

thanks for your help!!!! i have been beating myself trying to figure it out.

thanks once again!!!

best rgds
Gary

This question has already been answered. Start a new discussion instead.