Editing Files Opened for Random Access
To edit a random-access file, first read records from the file into program variables, and then change the values in the variables. In Declaring Variables for Random File Access and Opening Files for Random Access, a hypothetical Employee Records database defined variables for reading and writing employee records. The following step describes how to read and copy employee records using those variables.
To read and copy records into variables
- Use the FileGetObject Function, which copies a record from the Employee Records file into the
FileGet(FileNum, Employee, Position)
In this line of code,
FileNumcontains the number that the FileOpen Function used to open the file,
Positioncontains the number of the record to copy, and
Employee, declared as the user-defined type
Person, receives the contents of the record.
Declaring Variables for Random File Access | Opening Files for Random Access | Writing Variables to Records | File Access with Visual Basic Run-Time Functions | Sequential File Access | Binary File Access | FilePutObject Function | FileGetObject Function