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.
Printable View
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.
Can you post the code?
Regards,
The Beret.
The FileSystemObject's TextStream class's ReadLine method reads until it finds LF or CRLF pair... will that work?
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
Try to use
Line Input #1,MyString
instead of
input #1,MyString
Iouri Boutchkine
[email protected]
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
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
Hi John G
The code you posted works perfectly!
Thanks
qingbob