Dim Student As OneStudent Dim StudentName As String * 20 Dim CourseCode As String * 5 Open TextFile For Input As #1 Open RandomAccessFile For Random As #2 Len = 3125 Do While Not EOF(1) Input #1, StudentName, CourseCode Student.Name = StudentName Student.Code = CourseCode Put #2, , Student Loop Close #2 Close #1
[Note: The length of the random access file is 3125 because there are 125 student records, and each record is 25 (20+5) bytes]
Student is the record variable for the records. I have declared the record type in the General section like this:
Private Type OneStudent Name As String * 20 Code As String * 5 End Type
I have used a listbox to display the contents of the random access file to check if it works. But only the first record is there, and after that all is blank. This means that the records haven't been properly written to the random access file. I think the problem is here:
Put #2, , Student
But I don't know what the problem is. I am still trying to figure it out. Any help would be greatly appreciated.
This post has been edited by AN1554: 04 August 2011 - 10:44 AM