Solved

Writing text to a file, quotation marks doubling up VB6

Posted on 2013-01-03
6
349 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
Comment Utility
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 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
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
Comment Utility
... and would be saved as such

Print #f, strText
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 39

Expert Comment

by:als315
Comment Utility
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
Comment Utility
Thank you, that solved the problem
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now