trying to open a random access file
but i get an record length error for no reason i am aware of
please help if u know
Printable View
trying to open a random access file
but i get an record length error for no reason i am aware of
please help if u know
Code:Open "MYFILE.FIL" For Random As #1 Len = 1000
Put #1, recNum , data
Close #1
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