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

x
?
Solved

Write to textfile problem

Posted on 2004-08-24
5
Medium Priority
?
231 Views
Last Modified: 2010-05-02
Hi,

this is the problem I have:

I wrote a little program to write some data to a textfile.

Open "g:\transfer\convertedADBsap.txt" For Output As #1
...
Write #1, strDatum & strKey & strDescription
...
Close #1

This program works great but when I look in the created textfile(with notepad) I see:

"20040731 1 test"

I would like to become 20040731 1 test without the " ".  Is this possible? Suggestions?

Thanks
0
Comment
Question by:gollem
5 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11880237
Write #1, Trim(strDatum) & Trim(strKey) & Trim(strDescription)
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 200 total points
ID: 11880238
Open "g:\transfer\convertedADBsap.txt" For Output As #1
Print #1, strDatum & strKey & strDescription
Close #1
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11880253
Sorry I misunderstood.

Dim strText as String
strText = strDatum & strKey & strDescription
strText = Right(strText, Len(strText) - 1)
strText = Left(strText, Len(strText) - 1)
Write #1, strText
0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 80 total points
ID: 11880273
Yes it's possible:

Write places strings in double quotes, separates values with commas, and adds a CR/LF pair at the end of each command. Read the data back with Input.

Print does not add extra delimiters, but does concatenate a final CR/LF to each line. The CR/LF can be suppressed by ending the command with a semicolon (;). (This trick has been available in every Basic I've used, but it is not documented in the VB 6.0 Help.) Read it back with Line Input. (Line Input assumes a DOS type ASCII input file where each line is terminated with CR/LF. It does not recognize the unix line termination character.)

Print #1, strDatum & strKey & strDescription ;
0
 

Author Comment

by:gollem
ID: 11880408
Hi,

thanks guys exactly what I needed.  I'll give the points to mladenovicz because he had the fastest solution first, but I'll add 20 points for dhaest for his great comment.

JR2003 I've tested your solution but I still get " " in my textfile.

The print statement was the key I needed.

Thanks again for your time and quick reply.

Gollem
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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.
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…
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…
Suggested Courses

916 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