生徒の名前と成績のファイルを読み込んで、各カテゴリを別の配列に入れる必要があります。たとえば、すべての宿題 1 の成績を 1 つの配列に、宿題 2 の成績を別の配列に入れるなどですが、これを行う方法さえわかりません。これはこれまでの私のコードであり、そのほとんどが間違っていると確信しており、エラー メッセージが表示されます。
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