Solved

file output using write

Posted on 2000-03-28
10
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 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