Random access files are good only if you know the length of each record. If yes then I would suggest using user defined data type to populate the record data with. Lets say you have a record like this:
FirstName, LastName, Address, Phone
Code:Private Type Person strFirstName As String * 15 strLastName As String * 15 strAddress As String * 25 strPhone As String * 10 End Type Private Sub Command1_Click() Dim intFFN As Integer Dim udtRec As Pesron intFFN = FreeFile Open "C:\MyFile.txt" For Random As intFFN Len = Len(udtRec) Do Until EOF(intFFN) Get #intFFN, , udtRec With udtRec Debug.Print .strFirstName & " " & .strLastName & " " & .strAddress & " " & strPhone End With Loop Close #intFFN End Sub




Reply With Quote