Solved

Write to textfile problem

Posted on 2004-08-24
5
206 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 50 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 20 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 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

11 Experts available now in Live!

Get 1:1 Help Now