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?
hrolsonsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
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?
GrahamSkanRetiredCommented:
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.
hrolsonsAuthor Commented:
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

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Dennis AriesCEO @ Arkro ITCommented:
The print-command appends a newline. Try using the put-command instead, then you can specify exact what to write.

Dennis
GrahamSkanRetiredCommented:
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.
hrolsonsAuthor Commented:
It looks like what it's missing is a LF only.  Would I look for it using it's ASCII?
GrahamSkanRetiredCommented:
vbLf is the Virtual Basic constant name
GrahamSkanRetiredCommented:
The ASCII value is 10 (decimal)
hrolsonsAuthor Commented:
I tried vbLf and it didn't get rid of the darn thing.
hrolsonsAuthor Commented:
I ended up running this code to clean it up before writing, and it worked!!!

Function KillSpecialChars(InputStr As String) As String
    
    Dim InputLen As Long
    Dim Counter As Long
    Dim TestChar As String
    
    InputLen = Len(InputStr)
    
    For Counter = 1 To InputLen
        TestChar = Mid(InputStr, Counter, 1)
        Select Case Asc(TestChar)
            Case 32 To 126, 161 To 193, 194 To 255
                KillSpecialChars = KillSpecialChars & TestChar
            Case Else
                'do nothing
        End Select
    Next
    
End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.