Solved

Writing text to a file, quotation marks doubling up VB6

Posted on 2013-01-03
6
357 Views
Last Modified: 2013-01-03
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?
0
Comment
Question by:Crxfrd
[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
6 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38740263
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

0
 
LVL 48

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 38740265
If you are using Write # to create the file, use Print # instead. If not then please show your code.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38740276
... and would be saved as such

Print #f, strText
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Expert Comment

by:als315
ID: 38740310
Use WriteLine for writing CSV files (1- file No):
WriteLine(1, "01", "0", "IDNo", Var1, Var2)
Format Var1 and Var2 properly
0
 

Author Closing Comment

by:Crxfrd
ID: 38740570
Thank you, that solved the problem
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38740584
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
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

631 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