Trying to read a line from a file

  • Thread starter Thread starter jy836
  • Start date Start date
J

jy836

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
 
jy836 said:
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?
 
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
 
* "jy836 said:
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.
 
Back
Top