-
I have a little problem. My program allows users to delete records from a random access file. It also allows them to enter new records into the random access file. When they delete the record, the program just sets the record fields to "" So the record is still there, just nothing in it.
Since I don't want to waste to much space, when the user adds a new record, I want the program to look for the first 'available' record to use. By this I mean either the first deleted one it comes to, or add a new one to the end of file, which ever comes first. Then add that record number to a labels caption.
Here is the code I am using,
Code:
Dim QARec As QA
Dim i As Integer
Dim first As Integer
Dim filename As String
Dim questiontext As String
filename = strInstallPath & File1.filename
Open filename For Random As #1 Len = 1500
Do Until EOF(1)
i = i + 1
Get #1, i, QARec
questiontext = QARec.Question
If questiontext = "" Then
first = i
End If
Loop
Close #1
lblQuestionNumber.Caption = i
Also, if you notice I used EOF(1), is this the proper way to use it?
Thanks for any help you give.
-
MDB
you should look into using a database file as they are random access files with everything including the kitchen sink thrown in...
Perhaps this is a school project and you need to use a random file...in that case ignore this.
You can build a mdb...look under AddIns..Visual Data Manager
Visa Data....
-
I am just learning Visual Basic, and I want to learn Random Access Files. I do plan on converting the program over to a database type file storage, but for now I want to do it the Random way. Thanks anyway.
Anyone have a solution???????
-
HeSaidJoe:
THANK YOU!!
I have been needing MS access for such a long time..
and now i dont need it
THANK YOU!!!!!!
-
hmmm... anyway, I could still use an answer if anyone has one..