remove carriage returns

jspriet
jspriet used Ask the Experts™
on
Hi, I need to produce a file from VB 6 with Windows 2000 for Unix.
The file contains different lines all ending by a carriage return and a line feed (using the print method in VB).
As the file is destinated to a Unix System, I need to remove the carriage returns. How can I do that?

Thanks for your help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Use the "Replace" function (available since VB6) to replace all vbNewline
into vbNullString, and that is it.  If it is not CR + LF but just CR,
then use vbCR instead.

Author

Commented:
yes but replace function hanldes strings. If I want to write the string to the file, the print statement from VB will add a CR LF at the end of the line which I dont want...
Is there another way of writing to a file without inserting CR?
You could run a shell command to run a program which converts it for you just pass in the file name.

you can get some here -

http://www.bastet.com/software/software.html

(Unix2Dos and Dos2Unix)

for example

RetVal = Shell("DOS2UNIX.EXE" & Filenname, 1)
Ensure you’re charging the right price for your IT

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

Author

Commented:
Thats an option, but I dont want to use an external exe for that. I guess there might be a way to include that in the VB code.

If anybody could give me some info on that that would help me a lot...
Commented:
You said that you're printing to a file?  Simply append a semicolon to the end of your print statements like this:

...
print #1, "text to output";
...

Since you apparently want line-feeds, use this instead:

...
print #1, "text to output"; vbLF;
...

Author

Commented:
perfect that s exactly what I wanted to do. I wasnt aware of that.

Thanks very much, moreover it s way mor simple that I thought

Commented:
Glad it worked for you.

That feature (ending semicolon) is from the old days of Basic, and became undocumented when VB came along, and is really only available for backward compatibility.  Newer versions of VB assume that you'll use objects to handle all printing, and those objects let you control aspects such as line breaks.  However, my experience with their printing objects is that they are unnecessarily complicated, so I still use the old commands.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial