Link to home
Start Free TrialLog in
Avatar of wolfjjj
wolfjjj

asked on

file output using write

Greetings,

i was wondering if it is possible to stop VB from surrounding everything written to a file using 'write' in quotes ("")

eg
----

fileno = freefile
open app.path & "\test.txt" for output as fileno
write #fileno, "testing"
close fileno

----
ends up with a file containing

"testing"

Any ideas?
Avatar of Ark
Ark
Flag of Russian Federation image

Hi
If you are using Write to save strings with commas etc, you NEED this quotes to reed this file correctly next time. If you haven't commas etc, you can use Print statement:
Print #fileno,"testing"
Cheers
yeh, what ark said.

Write, outputs your data to a file, in a format that allows them to be correctly read in again using input.

this means your strings will be surrounded by quotes, and your date variables would be surrounded by #.

if your Saving data to a file, and want to be able to retrieve it accurately.

use Binary file access, and the Put and Get functions.

Gordon


The soultion is to use

ileno = freefile
                   open app.path & "\test.txt" for output as fileno
                   print #fileno, "testing"
                   close fileno
opps, already said
ditto.
My peers prefer the quotes for general import purposes, but I don't. So, RU
Done?
ASKER CERTIFIED SOLUTION
Avatar of monteh
monteh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great :-)
>You could also open the file for Binary.
> Open "c:\test2.txt" For Output As fileno
' write an ANSI string
>Put #fileno, , "testing"

First,
you'll get an Error, because though you wrote <binary>, in your code you open for Output.
Second,
You can also open the file for ANY to write the string, but only "Write" statement put quotes. First you have to decide - how will you read this file in future (see Gordonp comment).
Cheers
Avatar of monteh
monteh

Yes, sorry, I meant Open For Binary.
Avatar of wolfjjj

ASKER

graded so low because you got it right in your description, but your code let u down
I agree on comparative grade, but more 'cause I'd go with: follow the leads in Ark and Gordonp (even deighton) first.