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

x
?
Solved

Writing text to a file, quotation marks doubling up VB6

Posted on 2013-01-03
6
Medium Priority
?
363 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
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 49

Accepted Solution

by:
Martin Liss earned 2000 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
Industry Leaders: 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 49

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

877 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