There is an easy way to store 20 tests or however many maximum amount AND use it in an UDT AND store the UDT into a file!
Just setup a Student Tests String 3 times maximum of possible given tests (Numbered 1,2,3... like used in array)
With 3 characters reserved for each test, you can have scores from 0 to 999 but mostly 0 to 100 maybe extra credit on 100? it's available.
I have prepared a couple very simple routines for storing test scores into the Students Tests String that can be a fixed string of 60 characters for maximum 20 tests example.
Same approach can be taken for Assignments using more data strings for UDT and adding another parameter to Get and Put functions with string width of each data item.
Just setup a Student Tests String 3 times maximum of possible given tests (Numbered 1,2,3... like used in array)
With 3 characters reserved for each test, you can have scores from 0 to 999 but mostly 0 to 100 maybe extra credit on 100? it's available.
I have prepared a couple very simple routines for storing test scores into the Students Tests String that can be a fixed string of 60 characters for maximum 20 tests example.
Code: (Select All)
Dim studentTest3X20 As String * 60 ' fit 20 tests into fixed string that can be stored from UDT
Data 100,82,75,98,66
For i = 1 To 5 ' test PutTest loading the student test string with 5 tests
Read testscore
PutTest studentTest3X20, i, testscore
Next
' ok read back scores in reverse order
For i = 5 To 1 Step -1
Print GetTestScore(studentTest3X20, i)
Next
Sub PutTest (studentTest$, testNumber, testScore)
Mid$(studentTest$, testNumber * 3 - 2, 3) = Right$(" " + _Trim$(Str$(testScore)), 3)
End Sub
Function GetTestScore$ (studentTest$, testNumber)
GetTestScore$ = Mid$(studentTest$, testNumber * 3 - 2, 3)
End Function
Same approach can be taken for Assignments using more data strings for UDT and adding another parameter to Get and Put functions with string width of each data item.
b = b + ...