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 :)

commented: helpful info. +1

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)

Divide the results by the number of students if you really want averages :)

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

thanks once again!!!

best rgds
Gary

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.