Solved

file output using write

Posted on 2000-03-28
10
173 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:wolfjjj
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 28

Expert Comment

by:Ark
ID: 2666061
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
0
 
LVL 3

Expert Comment

by:Gordonp
ID: 2666188
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


0
 
LVL 18

Expert Comment

by:deighton
ID: 2666462
The soultion is to use

ileno = freefile
                   open app.path & "\test.txt" for output as fileno
                   print #fileno, "testing"
                   close fileno
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 18

Expert Comment

by:deighton
ID: 2666464
opps, already said
0
 
LVL 24

Expert Comment

by:SunBow
ID: 2675147
ditto.
My peers prefer the quotes for general import purposes, but I don't. So, RU
Done?
0
 

Accepted Solution

by:
monteh earned 15 total points
ID: 2685319
You could also open the file for Binary.

Open "c:\test2.txt" For Output As fileno
' write an ANSI string
Put #fileno, , "testing"
0
 
LVL 28

Expert Comment

by:Ark
ID: 2685599
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
0
 

Expert Comment

by:monteh
ID: 2685612
Yes, sorry, I meant Open For Binary.
0
 
LVL 1

Author Comment

by:wolfjjj
ID: 2706299
graded so low because you got it right in your description, but your code let u down
0
 
LVL 24

Expert Comment

by:SunBow
ID: 2708619
I agree on comparative grade, but more 'cause I'd go with: follow the leads in Ark and Gordonp (even deighton) first.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question