Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read a textfile 1

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
0
0
US
I get a text file without any line breaks.
It looks something like this:

1234567890~ABCDEFGH~0987654321~HHGFEDCBA~

So ~ means a new line.

I am using the streamreader.readline() method and it works fine when the file is like:
1234567890~
ABCDEFGH~
0987654321~
HHGFEDCBA~

How Can I read 1234567890~ABCDEFGH~0987654321~HHGFEDCBA~

Thanks in advance?
 
You could use the StreamReader.ReadToEnd method which will return all of the files contents to a string. Then use the String.Split function on this string and pass in the ~ as separator. This function will return each 1234567890 etc. into an array of strings.

Hope this helps!

Simon
 
store the string in a variable and then use Split function. something like this

Dim strLine As String
Dim arrData() As String

strLine = strStreamReader.ReadLine()
arrData = Split(strLine, "~")

then u can loop through arrData to get single line of data.

For more information visit the link below


===Please visit FAQs to view my contributions.===
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top