Click to See Complete Forum and Search --> : Reading from Sequential file
qingbob
October 24th, 2001, 02:51 AM
I want to write from a sequential file into a string, then from that string into another seq file. My problem is that it reads only the first line of the file or until it reaches a comma (,) replacing the string each time.
Green_Beret
October 24th, 2001, 05:13 AM
Can you post the code?
Regards,
The Beret.
DSJ
October 24th, 2001, 08:10 AM
The FileSystemObject's TextStream class's ReadLine method reads until it finds LF or CRLF pair... will that work?
qingbob
October 24th, 2001, 10:48 AM
Thanks for replies.
I have added the code I use, but this does not work, because it reads the delimmeters(vbcrlf, commas, etc)in the file thus overwriting the string each time. Is there another way?
PS. I want to manipulate the string, using the Mid$-function afterwards.Later more on that!
Thanks qingbob
Dim MyString as string
private Sub ReadString()
open "c:\TextFile.txt" for input as #1
While Not EOF(1)
input #1,MyString
Wend
Close #1
End Sub
Iouri
October 24th, 2001, 11:54 AM
Try to use
Line Input #1,MyString
instead of
input #1,MyString
Iouri Boutchkine
iouri@hotsheet.com
John G Duffy
October 24th, 2001, 12:02 PM
If you are looking to read an entire fiel into a variable complete with control characters, try this sample
Start a new project. add a command Button
Paste this code into the generral declartations section of the form.
Run the program and click the button
option Explicit
private Sub Command1_Click()
Dim a, strB
a = "C:\Autoexec.bat"
Open a for binary as #1
strB = input(FileLen(a), #1)
Close
Cls
print strB
End Sub
John G
qingbob
October 25th, 2001, 02:44 AM
Hi there
line input #1 - reads one line at a time, ignoring commas , but not newlines ,so it still overwrites the string, leaving the value
of the string equal to the last line of the textfile. I can read it into a string array, but
its gonna make my actual task much more complex.
(Lets use a TextFile which is a paragraph).
Thanks
qingbob
qingbob
October 25th, 2001, 10:46 AM
Hi John G
The code you posted works perfectly!
Thanks
qingbob
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.