|
-
July 22nd, 1999, 03:55 AM
#1
End-of-file in VB
Hello!
How can I set the end-of-file mark with VB5?
I use a data-file with my program and when user deletes some records I should delete them from
the data-file and decrease the data-file length.
Thanks!
Pasi Salminen
[email protected]
-
July 22nd, 1999, 04:56 AM
#2
Re: End-of-file in VB
what do you mean by a data-file, an access file or a text file (in case of a text file, how do you open it)
-
July 22nd, 1999, 05:16 AM
#3
Re: End-of-file in VB
Hi!
I'm using text file and I open it with Open method in VB. I can open the text file in mode which is needed to set end-of-file mark.
Pasi Salminen
[email protected]
-
July 22nd, 1999, 05:51 AM
#4
Re: End-of-file in VB
if you open the text file like this
open filename for input as #1
you can use
do until EOF(1)
something
loop
if you open it binary you have to calculate how many records there are in the file
to do that, you have to do something like this
size-of-file / size-of-record
If you want I can send you an example of a small application that uses text files
-
July 22nd, 1999, 06:08 AM
#5
Re: End-of-file in VB
I know how to write to the file, but how can I "shorten" the file.
In my program recordlength is 14 bytes and if there are for example 5 records the file-length is 70 bytes. If user deletes one record then I should "shorten" the file to 56 bytes (=70-14).
How can I do that? (Without deleting the hole file and creating new)
Pasi Salminen
[email protected]
-
July 22nd, 1999, 11:05 AM
#6
Re: End-of-file in VB
What do you do if the user deletes say record 2? do you move the rest of the records to fill the gap? (if you do that, you can just as easy create the new file..)
-
July 23rd, 1999, 12:51 AM
#7
Re: End-of-file in VB
Yes, I move the rest of the recors backwards.
I have solved the problem with API call to the SetEndOfFile function.
Thanks to all about advice!
Pasi Salminen
[email protected]
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
|