473,786 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to check for EOF (End of file) when using StreamReader to parse text file

How would I check for an end of file when parsing a text file using the
StreamReader object?

I would like to do something like this:

'************** *************** ***
Dim objStreamReader As StreamReader
Dim strReqLine As String

objStreamReader = File.OpenText(" data.txt")

While NOT objStreamReader .EOF

strReqLine = objStreamReader .ReadLine

'* Code to parse the line for data

End While
'************** *************** ***

Except the StreamReader object doesn't seem to have an EOF property. Are
there any work-arounds?

Thanks,

Sacha
Nov 17 '05 #1
2 15634
Sacha,

Just use:

While StreamReader.Re ad

End While

It will stop when it hits EOF.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Sacha Korell" <ko****@huntsvi lle.sparta.com> wrote in message
news:O$******** ********@tk2msf tngp13.phx.gbl. ..
How would I check for an end of file when parsing a text file using the
StreamReader object?

I would like to do something like this:

'************** *************** ***
Dim objStreamReader As StreamReader
Dim strReqLine As String

objStreamReader = File.OpenText(" data.txt")

While NOT objStreamReader .EOF

strReqLine = objStreamReader .ReadLine

'* Code to parse the line for data

End While
'************** *************** ***

Except the StreamReader object doesn't seem to have an EOF property. Are
there any work-arounds?

Thanks,

Sacha

Nov 17 '05 #2
Sacha,

strReqLine = objStreamReader .ReadLine()
While Not strReqLine Is Nothing
'* Code to parse the line for data
strReqLine = objStreamReader .ReadLine()
End While

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
12006
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to a new file. The script I have is giving me blank lines in the new file. #!/usr/local/bin/perl #program to read systemdata file #and write to systemstats file # #
2
12085
by: Tyaan | last post by:
Hi.. I'm a perl noob need to know how to write a script to parse a file containing one to four of the following blocks of text? I then want to print the results in a format showing the memory size (128) for each device that was found? Structure: Memory Device (Type 17) Type: 17 Length: 15h Handle: 0024h (36t) Memory Array Handle: 0021
4
4934
by: Patrick Blackman | last post by:
I have a text file embedded in my dll, how can I load that file without using the GetManifestResourceStream of the Assembly class, I want to read it as if it was just located in my c:\my document folder. Any ideas?
2
1980
by: Nathan Sokalski | last post by:
I have a page which reads the the first line of every *.txt file in a certain directory of mine to use as the Text property of a HyperLink Control. However, in one of my recently added text files in the directory it is using all but the ellipsis character (this is the last character in the line, but it does the same thing when I place the character in other places). For example, here is what the line looks like in the *.txt file and the...
3
18721
by: boukaka | last post by:
Hi there, I have a text file that does not have any delimiters - it is simply assumed that I know how long each field is and they are always in the same order. (i.e. JOHN DOE 12345606JUN072007JUL2009 34 PXP) Using C# I need to: 1. Grab the information in the text file. 2. Parse it out by grabbing the different "fields" (5th to 9th char = name, 24th to 27th is product etc). 3. Sort the fields into the order I want...
6
8601
by: trevor | last post by:
Incorrect values when using float.Parse(string) I have discovered a problem with float.Parse(string) not getting values exactly correct in some circumstances(CSV file source) but in very similar circumstances(XML file source) and with exactly the same value it gets it perfectly correct all the time. These are the results I got, XML is always correct, CSV are only incorrect for some of the values (above about 0.01) but always gives the...
7
18343
by: shantanu | last post by:
Hi all i am trying to save a excel file as a tab delimited text file. can i do it some how? i using the code _sheet1.SaveAs(@"C:\PRP \PRPTemp.txt",Excel.XlFileFormat.xlTextWindows ,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing); Kindly assist
5
6881
by: Rob | last post by:
Hi, I have a VB.Net application that parses an HTML file. This file was an MS Word document that was saved as web page. My application removes all unnecessary code generated by MS Word and does some custom formatting needed by my client. I use a StreamReader to read in the file...regular expressions to parse and clean up the file...and a StreamWriter to write the new file. On some HTML files that I parse, I get this character "á"...
10
1344
by: =?Utf-8?B?QXJ0eVNpbg==?= | last post by:
I'm trying to display a text file on a web page and the code below works fine and display the text on a webpage. However,if I use (as I need to) a masterpage and then place the code in a webform that uses the masterpage all it does is display the words 'Meeting minutes' which is the header for the text right at the bottom of the code below. Is there something in a masterpage that prevents this working at all? Cheers ArtySin <%@...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.