Re: Read/write files in VB
It would help if you attached the source file or at least posted a sample of it.
Re: Read/write files in VB
The application haven't started yet. Thats why she need a sampel.
Re: Read/write files in VB
There are countless samples about reading/writing from/to files all over the forums... just search for read and write...
Re: Read/write files in VB
Code:
The application should have limitation of the numbers of line for the content of the text files that can stored. Lets say the application will only stored 500 line for each text file, if the content of the text file reach 500 lines, it should automatically open another text file to write the content. When the program read back from the text files, it should get all the text files' content.
How about this section?
Re: Read/write files in VB
You can write to a file with a Print statement and increase a counter for 1 each time. When the counter reaches 500, go to the next file. The same goes for reading if you're doing it with a Line Input statement.
Re: Read/write files in VB
Here are a couple of threads in our FAQ forum.
http://vbforums.com/showthread.php?t=342619
http://vbforums.com/showthread.php?t=405051
Gavio, the links you posted are searchid's which are temporary. I think they get deleted after a day or so.
Re: Read/write files in VB
Code:
You can write to a file with a Print statement and increase a counter for 1 each time. When the counter reaches 500, go to the next file. The same goes for reading if you're doing it with a Line Input statement.
If i already storing records in 4 files (4 x 500 = 2000records)
and i removed record in the first file, then it will not read for the rest of the file but only get the first 499 record?
Can I use the UDP for storing in difference file?
Re: Read/write files in VB
Sounds like you need to use a database if your storing multiple files and that number of records.
Re: Read/write files in VB
I would like to but the server only allowed to stored using file system.
Re: Read/write files in VB
Quote:
Originally Posted by chthong
If i already storing records in 4 files (4 x 500 = 2000records) and i removed record in the first file, then it will not read for the rest of the file but only get the first 499 record?
Just out of couriosity... why are you limited to 500 records?
Quote:
Originally Posted by chthong
Can I use the UDP for storing in difference file?
Yes, but then saving and loading a file is done by Put and Get, not Input and Print/Write, since it's a binary file.
Re: Read/write files in VB
I also not sure, she didn't tell me why 500 records.
Do you have examples storing UDP in multiple files? Thanks
Re: Read/write files in VB
If this "records" are stored in one line per record, you can quite easly determine how many of theme are there:
VB Code:
Dim records As Integer
Open "c:\test1.txt" For Input As #1
records = UBound(Split(Input(LOF(1), 1), vbCrLf)) + 1
Close #1
Debug.Print "records: " & records
Also, i think it's a waist of time to work with text files in this mather. It would be much much easier to do it with a database, as RobDog already sead.