file output

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone. i'm using the following code to output to a text file

Open "C:\file.txt" For Output As #1

Write #1, string1
Write #1, string2

Close 1

This works well except for one problem the Write command seems to put
quatation marks around the strings("") is there a way to get rid of them or
another function i could use to output strings to files??
 
Use Print rather than Write.

Also, it's not a good idea to hard-code the file number like that. Use the
FreeFile function instead:

Dim lngFile As Long

lngFile = FreeFile
Open "C:\file.txt" For Output As #lngFile

Print #lngFile string1
Print #lngFile string2

Close #lngFile
 
OK thanks for the help

Douglas J Steele said:
Use Print rather than Write.

Also, it's not a good idea to hard-code the file number like that. Use the
FreeFile function instead:

Dim lngFile As Long

lngFile = FreeFile
Open "C:\file.txt" For Output As #lngFile

Print #lngFile string1
Print #lngFile string2

Close #lngFile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top