Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Writing to a file

Posted on 1998-12-11
5
Medium Priority
?
150 Views
Last Modified: 2010-05-03
Is there a easy way to write to  a file (i.e. output.txt) without having every thing surrounded by quotes.  If i open the file as random then i'm stuck with records and data types...
I want to be able to take some text and put it in a file without quotation marks...  Is it possible...???
0
Comment
Question by:jtjcomp
5 Comments
 
LVL 14

Accepted Solution

by:
waty earned 800 total points
ID: 1449535
  nFile = FreeFile
   Open sFile For Binary Access Write As #nFile

   Put #nFile, , "<DESTINATAIRE>" & NEW_LINE
   Put #nFile, , "<NOMD>" & gsUserNom & NEW_LINE
   Put #nFile, , "<PRENOMD>" & gsUserPrenom & NEW_LINE
   Put #nFile, , "<TITLE>" & gsUserTitle & NEW_LINE
   Put #nFile, , "<ETAGE>" & gsUserEtage & NEW_LINE
   Put #nFile, , "<BUREAU>" & gsUserBureau & NEW_LINE
   Put #nFile, , "<BATIMENT>" & gsUserBatiment & NEW_LINE
   Put #nFile, , "<FAX>" & gsUserFax & NEW_LINE
   Put #nFile, , "<PRINTGROUP>" & gsUserPrintGroup & NEW_LINE
   Put #nFile, , "</DESTINATAIRE>" & NEW_LINE

   Close #nFile
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1449536
Perhaps I may be able to help you on this one, but I'm not sure I understand your question - what is the significance of your remark "If you open the file as random then I'm stuck with records and data types..."

What exactly are you using this file for?

Regards,

Pino Carafa
0
 
LVL 4

Expert Comment

by:chabaud
ID: 1449537
Just open the file as text and use the print statement.

Open "output.txt" For Output As #1
print #1, "Hello world" & vbcrlf
close #1
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1449538
Yeah, standard sequential output uses quotes around the strings but the quotes themselves are *NOT* written to the file. If you have the text in a var *ONLY* the contents of the string is sent. No quotes.

M

0
 
LVL 1

Expert Comment

by:OeilNoir
ID: 1449539
if you want to increase the flexibility, if you either read or Write and don't want quotes and such, i think the best way would be with
"binary"

open "c:\file.ext" for binary as #1
put #1,, stringvariable
close #1


0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

885 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