|
-
Mar 23rd, 2002, 09:20 PM
#1
Thread Starter
Fanatic Member
Write #
anybody ever had any problems using the write # statement with a string that contained double quotes "?
i see that it writes it to the file like..
"this is ""my"" text"
but when it goes to read it with input #, it fails to do so correctly
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Mar 23rd, 2002, 09:28 PM
#2
Try saving it using the Print statement instead.
-
Mar 23rd, 2002, 10:18 PM
#3
Thread Starter
Fanatic Member
MSDN says use write because it formats the data so that input can read it, otherwise if you use print you have to delimit it yourself
"Note If, at some future time, you want to read the data from a file using the Input # statement, use the Write # statement instead of the Print # statement to write the data to the file. Using Write # ensures the integrity of each separate data field by properly delimiting it, so it can be read back in using Input #. Using Write # also ensures it can be correctly read in any locale."
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Mar 23rd, 2002, 10:25 PM
#4
In the example you provided, print would be fine. I think the problem come in when you try to save comma or tab delimited file.
-
Mar 24th, 2002, 02:14 PM
#5
Thread Starter
Fanatic Member
well that example wasn't completely accurate, really i need to save data that is maybe a page long with newlines in it and then later on in the file in need to save other things like numbers and stuff
print/input isn't working either for this
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Mar 24th, 2002, 02:40 PM
#6
Lively Member
Might help
use chr$(34) instead of Quote
Private Sub WriteFile()
Dim F As Integer
F = FreeFile
Open "C:\test.txt" For Output As F
Print #F, "Testing " & Chr$(34) & Chr$(34) & "OK" & Chr$(34) & Chr$(34)
Close F
End Sub
Private Sub ReadFile()
Dim F As Integer, str As String
F = FreeFile
Open "C:\test.txt" For Input As F
While Not EOF(F)
Line Input #F, str
MsgBox str
Wend
Close F
End Sub
this reads double quotes OK
-
Mar 24th, 2002, 03:46 PM
#7
Addicted Member
Couldn't you write it into the text file this way:
VB Code:
Write #1, "This is " & Chr(34) & "My" & Chr(34) & " String"
Who needs rhetorical questions anyway?
Bazza NET - The place you want to be!

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|