Using arrays in/with structures.

wangj

Member
Joined
Jul 2, 2008
Messages
5
Programming Experience
Beginner
Hi all, I'm currently doing this project where i have to create a program that let's the administrator manage students (and their tests.) I have decided to use Random Access file in this project.
because structures will need fixed lengths...i don't know how will i search through the students (a function of the program) when each student structure has a different length because of the number of tests they've done.
* I have created a variable in the aStudent structure so that i can know the number of tests a student has done...but don't know how to use it.
Here's my code:

VB.NET:
Public Class FormAdmin
    Dim currentStudentName As String
    Dim currentStudentID As Integer = 0
    Dim filePath As String = Application.ExecutablePath + "StudentData.dat"
    Dim oneStudent As aStudent
    Structure aStudent
        <VBFixedString(30)> Dim studentName As String
        Dim studentID As Short
        Dim totalTestDone As Short
        Dim thisTest() As Test
    End Structure
    Structure Test
        Dim testDate As System.DateTime
        <VBFixedString(14)> Dim testType As String
        Dim questionAnswered As Integer
        Dim questionCorrect As Integer
		dim timeTaken as integer
    End Structure

Thanks~
 
First up, you may as well get rid of those VBFixedString attributes because they are pointless. There's no way to make a String a fixed size. That attribute simply makes a String look like it's a fixed size when being passed to unmanaged code that requires it.

You would have to seek to the beginning of a student record, then seek to position of the totalTestDone value. You'll then have to read that value and then seek ahead the number multiplied by the length of a test record.
 
hmm, it returns an error saying bad file length, seems like i still need the <VBFixedString(18)> (i'm using 2005 btw)

I'm still stuck on how i will retrieve previous data(test data) using arrays...can someone help?
 
Back
Top