Good morning,

Can someone help me code this instruction?

Place student names and final mark into two, one- dimensional arrays. One array will be of String (for names), the other will be an array for real numbers (for marks)

Use the array to display:
Class Average
The number of students above the class average

With what array you are having trouble with?

one dimensional array, and trying to figure out if I should used a public sub or public function to declare and get result

for example:

Public Function ClassAverage(ByVal Average As String)

    Dim Grades() As Decimal = {76.5D, 63.4D, 45.4D, 94.5D, 81.3D, 66.2D, 68.6D}
    Dim sum As Decimal = 0

    For intCounter As Integer = 0 To Grades.Length - 1
        sum += Grades(intCounter)
    Next

    Average = (sum / Grades.Length)

    Return Average

End Function

I HAVE TWO ERRORS THAT I DON'T UNDERSTAND

Don't know about your two errors, you don't explain them.
Perhaps as a start you could try this:
Public Function ClassAverage(ByVal grades As Decimal()) As Decimal

My errors have gone and I have asked Grades to return. Now when I go to write:

FileOpen(2, strFilename, OpenMode.Append)
            Write(Grades + vbTab + vbCrLf + vbCrLf)
            FileClose()



        I have an error: Grades is not declared

Your function ClassAverage returns nothing.

Have you declared Grades?

Do you mean something like this:

Dim Grades As Decimal = ClassAverage("TESTSTRING")
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.