02-15-2023, 12:59 PM
Looking at your data format, here's how I'd read and write that data to keep it simple and efficient.
1)Determine the MAX number of students that a class would ever hold, then round up to the nearest 10s. (For 23 students, round to 30, for example.)
2)Since text files are tiny and hard drives are huge, DOUBLE that number for "future proofing" your database. (That 23 just became 60.)
Now that you have a set number of elements to work with, take a close look at your data. What I'd do is store my data in two arrays, based off the same index -- StudentName(100) As String * 100 and Grades(100,100) AS SINGLE. Basically:
Dim StudentName(100) As String * 100
Dim Grades(100,100) AS SINGLE
Now I can use one binary file to hold all my data in, and I can access any part of it instantly.
Write StudentName() to the file first, as a header.
Write Grades() to the file next.
Depending on how you index that Grades array, your students grades will each be placed left to right or from top to bottom, but either way they'll be in a sequential order.
Want Ami Li's test result for her third test? It's in that file at position (100 * 100 for the name header = 10000) + 400 * 1st Index + 4 * 2nd Index (based off Grades (x, y) <-- x and y are your indexes).
A database much larger than you currently need for future proofing, that offers instant access to any cell of information which you want. What could be better than that?
1)Determine the MAX number of students that a class would ever hold, then round up to the nearest 10s. (For 23 students, round to 30, for example.)
2)Since text files are tiny and hard drives are huge, DOUBLE that number for "future proofing" your database. (That 23 just became 60.)
Now that you have a set number of elements to work with, take a close look at your data. What I'd do is store my data in two arrays, based off the same index -- StudentName(100) As String * 100 and Grades(100,100) AS SINGLE. Basically:
Dim StudentName(100) As String * 100
Dim Grades(100,100) AS SINGLE
Now I can use one binary file to hold all my data in, and I can access any part of it instantly.
Write StudentName() to the file first, as a header.
Write Grades() to the file next.
Depending on how you index that Grades array, your students grades will each be placed left to right or from top to bottom, but either way they'll be in a sequential order.
Want Ami Li's test result for her third test? It's in that file at position (100 * 100 for the name header = 10000) + 400 * 1st Index + 4 * 2nd Index (based off Grades (x, y) <-- x and y are your indexes).
A database much larger than you currently need for future proofing, that offers instant access to any cell of information which you want. What could be better than that?