我必须读入学生姓名和成绩的文件,并将每个类别放入一个单独的数组中,例如一个数组中的所有 homework1 成绩,另一个数组中的 homework2 成绩等,但我什至不知道该怎么做。到目前为止,这是我的代码,我确信其中大部分是错误的,并且我有错误消息。
Public Class frmGrades
Dim FirstName As Array
Dim LastName As Array
Dim HW1 As Array
Dim HW2 As Array
Dim Project As Array
Dim Midterm As Array
Dim Final As Array
Dim Average As Array
Dim record, fields(7) As String
Dim inFile As StreamReader
Dim outFile As StreamWriter
Private Sub cmdReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReport.Click
MsgBox("Summary report has been created", MsgBoxStyle.OkOnly, "Grades")
End Sub
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
Me.Close()
End Sub
Private Sub frmGrades_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
inFile = File.OpenText("Grades.csv")
outFile = File.CreateText("Report.csv")
Do While (inFile.Peek <> -1)
record = inFile.ReadLine
fields = Split(record, ",")
FirstName = CInt(fields(0))
LastName = fields(1)
HW1 = fields(2)
HW2 = fields(3)
Project = fields(4)
Midterm = fields(5)
Final = fields(6)
'Average = (HW1 * 0.0833) + (HW2 * 0.0833) + (Project * 0.1666) + (Midterm * 0.3332) + (Final * 0.3332)
outFile.Write(FirstName)
outFile.Write(LastName)
outFile.Write(HW1)
outFile.Write(HW2)
outFile.Write(Project)
outFile.Write(Midterm)
outFile.Write(Final)
outFile.WriteLine(Average)
Loop
End Sub
Private Function Split(ByVal record As String, ByVal p2 As String) As String()
Throw New NotImplementedException
End Function
End Class