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?
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?
0
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.
0
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

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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
0
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.
0
hrolsonsAuthor Commented:
It looks like what it's missing is a LF only.  Would I look for it using it's ASCII?
0
GrahamSkanRetiredCommented:
vbLf is the Virtual Basic constant name
0
GrahamSkanRetiredCommented:
The ASCII value is 10 (decimal)
0
hrolsonsAuthor Commented:
I tried vbLf and it didn't get rid of the darn thing.
0
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

1

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.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.