471,853 Members | 927 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

Trying to read a line from a file

Hi again. <g> This time, I'm having trouble reading a single line from a
file. The line reads, "DBPATH=[full path of database file goes here]." But
when I use the Input function, it only writes to the variable up to the
first space in the path. In other words, if the path was
"C:\Software\Utilities and Applications," the variable would read,
"DBPATH=C:\Software\Utilities." It basically determines a space to be the
beginning of a new section of the file or something. How can I get it to
read an entire line?? Thanks...

Jay
Nov 20 '05 #1
3 1028
"jy836" <mo***@nospam.com> schrieb
Hi again. <g> This time, I'm having trouble reading a single line
from a file. The line reads, "DBPATH=[full path of database file goes
here]." But when I use the Input function, it only writes to the
variable up to the first space in the path. In other words, if the
path was "C:\Software\Utilities and Applications," the variable would
read, "DBPATH=C:\Software\Utilities." It basically determines a space
to be the beginning of a new section of the file or something. How
can I get it to read an entire line?? Thanks...

Hmmm.... Use LineInput instead?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Cor
Hi Jy836 are you sure it is a common. txt file?

And otherwise use the streamreader as sample written here watch typos.
\\\
Try
Dim sr As StreamReader = New StreamReader("MyFile.txt")
Dim line As String
line = sr.ReadLine
Do until line Is Nothing
messagebox.show(line)
line = sr.ReadLine
Loop
sr.Close
Catch Ex As Exception
messagebox.show(Ex.Message)
End Try
///
I hope this helps

Cor
Nov 20 '05 #3
* "jy836" <mo***@nospam.com> scripsit:
Hi again. <g> This time, I'm having trouble reading a single line from a
file. The line reads, "DBPATH=[full path of database file goes here]." But
when I use the Input function, it only writes to the variable up to the
first space in the path. In other words, if the path was
"C:\Software\Utilities and Applications," the variable would read,
"DBPATH=C:\Software\Utilities." It basically determines a space to be the
beginning of a new section of the file or something. How can I get it to
read an entire line?? Thanks...


Use 'PrintLine' for writing the line and 'LineInput' to read the line.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Rich Grise | last post: by
4 posts views Thread by yo_mismo | last post: by
1 post views Thread by Ty Moffett | last post: by
1 post views Thread by James Johnston | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

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.