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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 714
  • Last Modified:

How to remove double-quotes when writing to a text file?

Hi all,

I have a program to write the content of a document to a text file when the user clicks on a button.

Here is a part of the program:

fileNum = Freefile()
fileName = "C:\Sample.txt"
Open fileName For Output As fileNum
tmpContent = doc.P1(0) +"|"+ doc.T1(0) +"|"+ doc.DSO1(0) +"|"+ doc.DO1(0) +"|"+ doc.PS1(0) +"|"+ doc.PSG1(0) +"|"+ _
doc.RS1(0) +"|"+ doc.PO1(0) +"|"+ doc.POG1(0) +"|"+ doc.RO1(0) +"|"+ doc.S1(0) +"|"+ doc.OI1(0) +"|"+ doc.CL(0)
Write #fileNum, tmpContent
Close fileNum

However, after writing to the text file, the content in the text file is wrapped by "double-quotes", eg. "abc|def|ghi|jkl|mno|pqr".
How can I remove the double-quotes?

Thanks very much in advance!

kspuea
0
kspuea
Asked:
kspuea
  • 2
1 Solution
 
RanjeetRainCommented:
Try opening the file for BINARY access.
0
 
RanjeetRainCommented:
Also, declare tmpContent as String explicitly.
0
 
qwaleteeCommented:
Hi jjperez2,

Replace the "WRITE" statement with a "PRINT" statement, like so:

Print #fileNum, tmpContent

The WRITE statment always uses delimiters:
Write # statement  

Writes data to a sequential text file with delimiting characters.

Numeric      Omits leading and trailing spaces.
String      Encloses all strings in double quotation marks. Pads fixed-length strings with spaces as needed.



Best regards,
qwaletee
0
 
kspueaAuthor Commented:
Hi qwalette, thanks very much! Your method works wonderfully!
Finally I solved my problem.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now