|
-
May 27th, 2001, 01:32 PM
#1
Thread Starter
New Member
Problem with random access file
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
-
May 27th, 2001, 01:45 PM
#2
Code:
Open "MYFILE.FIL" For Random As #1 Len = 1000
Put #1, recNum , data
Close #1
-
May 27th, 2001, 02:34 PM
#3
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|