By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,582 Members | 1,720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,582 IT Pros & Developers. It's quick & easy.

reading text files

P: n/a
Hi,

I have a text file that is made of a number of paragraphs:

each paragraph start with either: ":O", ":N", or ":" follow by a 4
digit number and finish with either: M30 or M99

What I need to do is go down the file and capture the text between and
create a new text file for each occurrence using the name of the
original file plus the first line less the ":"

Orginal file: 625.txt

:1041
text here
text here
text there
M30
:2393
text here
text here
text there
text here
text hereM30
:N2112
text here
text here
M99

the end result will be: 3 files 6251041.txt, 6252393.txt and
6252112.txt

I hope you guys can help me

Regards,

Bre-x
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Bre-x" <ch*******@hotmail.com> schrieb:
I have a text file that is made of a number of paragraphs:

each paragraph start with either: ":O", ":N", or ":" follow by a 4
digit number and finish with either: M30 or M99

What I need to do is go down the file and capture the text
between and create a new text file for each occurrence using
the name of the original file plus the first line less the ":"


Basic code for reading the lines of a file:

\\\
Imports System.IO
..
..
..
Dim sr As New StreamReader("C:\WINDOWS\WIN.INI")
Dim strLine As String
strLine = sr.ReadLine()
Do Until strLine Is Nothing
MsgBox(strLine)
strLine = sr.ReadLine()
Loop
sr.Close()
///

Have a look at the 'StreamWriter' class. This class can be used to write
data to a file.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2

P: n/a
"Bre-x" <ch*******@hotmail.com> schrieb
Hi,

I have a text file that is made of a number of paragraphs:

each paragraph start with either: ":O", ":N", or ":" follow by a 4
digit number and finish with either: M30 or M99

What I need to do is go down the file and capture the text between
and create a new text file for each occurrence using the name of
the original file plus the first line less the ":"

Orginal file: 625.txt

:1041
text here
text here
text there
M30
:2393
text here
text here
text there
text here
text hereM30
:N2112
text here
text here
M99

the end result will be: 3 files 6251041.txt, 6252393.txt and
6252112.txt

I hope you guys can help me


Did you already have a look at the System.IO namespace?

See also:

Visual Studio.NET
.NET Framework
Programming with .NET Framework
-> Working with I/O
Visual Basic and Visual C#
Reference
Visual Basic language
Visual Basic Language Tour
-> Processing drives, folders and files
--
Armin

Nov 20 '05 #3

P: n/a
Hi Bre-x,

If you're still having difficulty after reading the references given, come back and add to thi thread.

Regards,
Fergus
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.