|
-
Oct 26th, 2006, 10:51 PM
#1
Thread Starter
Lively Member
Read/write files in VB
My friend need to do a application that able to read from a file to get some parameters for the application to run. The application will then generate some data into another text file (storing informations). 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.
Anyone have similar sampel program in VB? Thanks in advance.
</HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
<?PHP
$j=0;
for($j=0;$j<=9999;$j++){
echo 'Why job is so boring<BR>';
}
?>
Just want to test does it works?
-
Oct 26th, 2006, 11:02 PM
#2
Addicted Member
Re: Read/write files in VB
It would help if you attached the source file or at least posted a sample of it.
-
Oct 26th, 2006, 11:13 PM
#3
Thread Starter
Lively Member
Re: Read/write files in VB
The application haven't started yet. Thats why she need a sampel.
</HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
<?PHP
$j=0;
for($j=0;$j<=9999;$j++){
echo 'Why job is so boring<BR>';
}
?>
Just want to test does it works?
-
Oct 27th, 2006, 01:05 AM
#4
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...
-
Oct 27th, 2006, 01:37 AM
#5
Thread Starter
Lively Member
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?
</HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
<?PHP
$j=0;
for($j=0;$j<=9999;$j++){
echo 'Why job is so boring<BR>';
}
?>
Just want to test does it works?
-
Oct 27th, 2006, 01:42 AM
#6
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.
-
Oct 27th, 2006, 01:49 AM
#7
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 27th, 2006, 02:05 AM
#8
Thread Starter
Lively Member
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?
</HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
<?PHP
$j=0;
for($j=0;$j<=9999;$j++){
echo 'Why job is so boring<BR>';
}
?>
Just want to test does it works?
-
Oct 27th, 2006, 02:14 AM
#9
Re: Read/write files in VB
Sounds like you need to use a database if your storing multiple files and that number of records.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 27th, 2006, 04:52 AM
#10
Thread Starter
Lively Member
Re: Read/write files in VB
I would like to but the server only allowed to stored using file system.
</HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
<?PHP
$j=0;
for($j=0;$j<=9999;$j++){
echo 'Why job is so boring<BR>';
}
?>
Just want to test does it works?
-
Oct 27th, 2006, 06:24 AM
#11
Re: Read/write files in VB
 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?
 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.
-
Oct 27th, 2006, 06:42 AM
#12
Thread Starter
Lively Member
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
</HTML><SCRIPT>alert('Why job is so boring?')</SCRIPT>
<?PHP
$j=0;
for($j=0;$j<=9999;$j++){
echo 'Why job is so boring<BR>';
}
?>
Just want to test does it works?
-
Oct 27th, 2006, 12:52 PM
#13
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.
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
|