Link to home
Start Free TrialLog in
Avatar of Gary Croxford
Gary CroxfordFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Writing text to a file, quotation marks doubling up VB6

Thank you for lookig at my question,

I am trying to output a line of data to a text file as a string in the format:

"01","0","IDNo","Hour:Minutes","DD/MM/YYYY","WeekDayNo"

The Hours, Minutes, Date and Day Number are derived from declared values but the first part of the string - "01","0","IDNo" -  is hard-coded.

I can reproduce the string in the format I need in a msgbox as check on what is about to be written to the file but whether I use Chr$(34) or two double quotation marks the text in the output file always has double double-quotes in the body of the string.

"01"",""0"",""IDNo"",""Hour:Minutes"",""DD/MM/YYYY"",""WeekDayNo"

How do I force only single instances of double-quotes?
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

This displays in standard CSV format
Dim strText As String

strText = """01"",""0"",""IDNo"",""Hour:Minutes"",""DD/MM/YYYY"",""WeekDayNo"""
MsgBox strText

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
... and would be saved as such

Print #f, strText
Use WriteLine for writing CSV files (1- file No):
WriteLine(1, "01", "0", "IDNo", Var1, Var2)
Format Var1 and Var2 properly
Avatar of Gary Croxford

ASKER

Thank you, that solved the problem
You're welcome and I'm glad I was able to help.

The 'About Me' page in My profile contains links to some articles I've written that may interest you.
Marty - MVP 2009 to 2012