Link to home
Start Free TrialLog in
Avatar of hrolsons
hrolsonsFlag for United States of America

asked on

Trying to get rid of hard return in text

So I have a program that writes out a text file.  Everything is working fine, but I need to get rid of any hard returns before writing to the text file.  I tried:

txtText1=replace(txtText1,vbCrLf,"<P>")

But I'm still ending up with hard returns in the final file.

Any ideas?
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Some output methods will automatically append a line feed and/or a carriage with each output record.

What method are you using to write to the output file?
Note also, that  your input data does not necessarily have both  a new line and a carriage return to delimit the records. Some environments use only one, so your Replace() wouldn't then be appropriate.
Avatar of hrolsons

ASKER

Here is the code that I'm using:

        intFileHandle = FreeFile
        Open App.Path & "\myfile.csv" For Append As #intFileHandle
        Print #intFileHandle, myStr
        Close #intFileHandle

Open in new window

The print-command appends a newline. Try using the put-command instead, then you can specify exact what to write.

Dennis
You can use a Put statement. For that you must have opened the output file for Binary or Random.
However, judging by the file extension of .csv,  you need a normally delimited text file.
If you are trying to add something to each line of a CSV file, just append the new  text to the original text line and output each line as a whole.
It looks like what it's missing is a LF only.  Would I look for it using it's ASCII?
vbLf is the Virtual Basic constant name
The ASCII value is 10 (decimal)
I tried vbLf and it didn't get rid of the darn thing.
ASKER CERTIFIED SOLUTION
Avatar of hrolsons
hrolsons
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.