PC Review


Reply
Thread Tools Rate Thread

Carriage Return

 
 
Francis Ang
Guest
Posts: n/a
 
      3rd Apr 2009
I am using REPLACE command to remove carriage return and line feed from a
text file; but when I rename the text file from 'abc.txt' to 'abc.hex', the
carriage return mysteriously reappears.

I tried using the REPLACE command on 'abc.hex' file but it is not working.
REPLACE seems to work on text file only.

Any assistance will be greatly appreciated.

Thank you.


 
Reply With Quote
 
 
 
 
joel
Guest
Posts: n/a
 
      3rd Apr 2009
I would like to see your code. Especially the way you are opening the file.
thre are some defaults on how the file is being opened. You ca open the file
as text or Unicode. You may be opening the file as unicode which really are
16 bit characters instead of 8 bit characters.I would also like to see your
replace statement.

"Francis Ang" wrote:

> I am using REPLACE command to remove carriage return and line feed from a
> text file; but when I rename the text file from 'abc.txt' to 'abc.hex', the
> carriage return mysteriously reappears.
>
> I tried using the REPLACE command on 'abc.hex' file but it is not working.
> REPLACE seems to work on text file only.
>
> Any assistance will be greatly appreciated.
>
> Thank you.
>
>

 
Reply With Quote
 
Francis Ang
Guest
Posts: n/a
 
      3rd Apr 2009
Hi Joel,

Thank you for responding so quickly. As requested, here is the code I wrote -

Sub CarriageRmv()
Open "C:\abc.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, cData

cDataNoCrLf = Replace(cData, vbCrLf, "")

Open "C:\NoCrLF.txt" For Append As #2
Print #2, cDataNoCrLf
Close #2

If EOF(1) Then
Close #1
Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
Exit Sub
End If
Loop
End Sub


"joel" wrote:

> I would like to see your code. Especially the way you are opening the file.
> thre are some defaults on how the file is being opened. You ca open the file
> as text or Unicode. You may be opening the file as unicode which really are
> 16 bit characters instead of 8 bit characters.I would also like to see your
> replace statement.
>
> "Francis Ang" wrote:
>
> > I am using REPLACE command to remove carriage return and line feed from a
> > text file; but when I rename the text file from 'abc.txt' to 'abc.hex', the
> > carriage return mysteriously reappears.
> >
> > I tried using the REPLACE command on 'abc.hex' file but it is not working.
> > REPLACE seems to work on text file only.
> >
> > Any assistance will be greatly appreciated.
> >
> > Thank you.
> >
> >

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      3rd Apr 2009
Print statements put a CarriageReturn/LineFeed combination at the end of
each line it prints by default. You can suppress this default functionality
by placing a semi-colon at the end of the Print statement. Try it this
way...

Print #2, cDataNoCrLf;

Notice the semi-colon at the end of the statement.

--
Rick (MVP - Excel)


"Francis Ang" <(E-Mail Removed)> wrote in message
news:848E7D5F-6EBD-4C9A-928F-(E-Mail Removed)...
> Hi Joel,
>
> Thank you for responding so quickly. As requested, here is the code I
> wrote -
>
> Sub CarriageRmv()
> Open "C:\abc.txt" For Input As #1
> Do While Not EOF(1)
> Line Input #1, cData
>
> cDataNoCrLf = Replace(cData, vbCrLf, "")
>
> Open "C:\NoCrLF.txt" For Append As #2
> Print #2, cDataNoCrLf
> Close #2
>
> If EOF(1) Then
> Close #1
> Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
> Exit Sub
> End If
> Loop
> End Sub
>
>
> "joel" wrote:
>
>> I would like to see your code. Especially the way you are opening the
>> file.
>> thre are some defaults on how the file is being opened. You ca open the
>> file
>> as text or Unicode. You may be opening the file as unicode which really
>> are
>> 16 bit characters instead of 8 bit characters.I would also like to see
>> your
>> replace statement.
>>
>> "Francis Ang" wrote:
>>
>> > I am using REPLACE command to remove carriage return and line feed from
>> > a
>> > text file; but when I rename the text file from 'abc.txt' to 'abc.hex',
>> > the
>> > carriage return mysteriously reappears.
>> >
>> > I tried using the REPLACE command on 'abc.hex' file but it is not
>> > working.
>> > REPLACE seems to work on text file only.
>> >
>> > Any assistance will be greatly appreciated.
>> >
>> > Thank you.
>> >
>> >


 
Reply With Quote
 
Francis Ang
Guest
Posts: n/a
 
      3rd Apr 2009
Thank you, Rick,

It works! The semi-colon did the trick.

Thank you.

"Rick Rothstein" wrote:

> Print statements put a CarriageReturn/LineFeed combination at the end of
> each line it prints by default. You can suppress this default functionality
> by placing a semi-colon at the end of the Print statement. Try it this
> way...
>
> Print #2, cDataNoCrLf;
>
> Notice the semi-colon at the end of the statement.
>
> --
> Rick (MVP - Excel)
>
>
> "Francis Ang" <(E-Mail Removed)> wrote in message
> news:848E7D5F-6EBD-4C9A-928F-(E-Mail Removed)...
> > Hi Joel,
> >
> > Thank you for responding so quickly. As requested, here is the code I
> > wrote -
> >
> > Sub CarriageRmv()
> > Open "C:\abc.txt" For Input As #1
> > Do While Not EOF(1)
> > Line Input #1, cData
> >
> > cDataNoCrLf = Replace(cData, vbCrLf, "")
> >
> > Open "C:\NoCrLF.txt" For Append As #2
> > Print #2, cDataNoCrLf
> > Close #2
> >
> > If EOF(1) Then
> > Close #1
> > Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
> > Exit Sub
> > End If
> > Loop
> > End Sub
> >
> >
> > "joel" wrote:
> >
> >> I would like to see your code. Especially the way you are opening the
> >> file.
> >> thre are some defaults on how the file is being opened. You ca open the
> >> file
> >> as text or Unicode. You may be opening the file as unicode which really
> >> are
> >> 16 bit characters instead of 8 bit characters.I would also like to see
> >> your
> >> replace statement.
> >>
> >> "Francis Ang" wrote:
> >>
> >> > I am using REPLACE command to remove carriage return and line feed from
> >> > a
> >> > text file; but when I rename the text file from 'abc.txt' to 'abc.hex',
> >> > the
> >> > carriage return mysteriously reappears.
> >> >
> >> > I tried using the REPLACE command on 'abc.hex' file but it is not
> >> > working.
> >> > REPLACE seems to work on text file only.
> >> >
> >> > Any assistance will be greatly appreciated.
> >> >
> >> > Thank you.
> >> >
> >> >

>
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      3rd Apr 2009
One more, you can also use...

Write #1, cDataNoCrLf

If this post helps click Yes
---------------
Jacob Skaria


"Francis Ang" wrote:

> Thank you, Rick,
>
> It works! The semi-colon did the trick.
>
> Thank you.
>
> "Rick Rothstein" wrote:
>
> > Print statements put a CarriageReturn/LineFeed combination at the end of
> > each line it prints by default. You can suppress this default functionality
> > by placing a semi-colon at the end of the Print statement. Try it this
> > way...
> >
> > Print #2, cDataNoCrLf;
> >
> > Notice the semi-colon at the end of the statement.
> >
> > --
> > Rick (MVP - Excel)
> >
> >
> > "Francis Ang" <(E-Mail Removed)> wrote in message
> > news:848E7D5F-6EBD-4C9A-928F-(E-Mail Removed)...
> > > Hi Joel,
> > >
> > > Thank you for responding so quickly. As requested, here is the code I
> > > wrote -
> > >
> > > Sub CarriageRmv()
> > > Open "C:\abc.txt" For Input As #1
> > > Do While Not EOF(1)
> > > Line Input #1, cData
> > >
> > > cDataNoCrLf = Replace(cData, vbCrLf, "")
> > >
> > > Open "C:\NoCrLF.txt" For Append As #2
> > > Print #2, cDataNoCrLf
> > > Close #2
> > >
> > > If EOF(1) Then
> > > Close #1
> > > Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
> > > Exit Sub
> > > End If
> > > Loop
> > > End Sub
> > >
> > >
> > > "joel" wrote:
> > >
> > >> I would like to see your code. Especially the way you are opening the
> > >> file.
> > >> thre are some defaults on how the file is being opened. You ca open the
> > >> file
> > >> as text or Unicode. You may be opening the file as unicode which really
> > >> are
> > >> 16 bit characters instead of 8 bit characters.I would also like to see
> > >> your
> > >> replace statement.
> > >>
> > >> "Francis Ang" wrote:
> > >>
> > >> > I am using REPLACE command to remove carriage return and line feed from
> > >> > a
> > >> > text file; but when I rename the text file from 'abc.txt' to 'abc.hex',
> > >> > the
> > >> > carriage return mysteriously reappears.
> > >> >
> > >> > I tried using the REPLACE command on 'abc.hex' file but it is not
> > >> > working.
> > >> > REPLACE seems to work on text file only.
> > >> >
> > >> > Any assistance will be greatly appreciated.
> > >> >
> > >> > Thank you.
> > >> >
> > >> >

> >
> >

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      3rd Apr 2009
I believe using Write on the OP's text file will encase the entire file in
quote marks. And, if the text contains quoted text within it, I believe
there will be some problems around those embedded text strings also. I
decided early on (maybe 25 years ago or so) to avoid using Write to put data
into a file because of what I considered at the time to be some odd
behaviors... in any event, I've found Print to do all I have ever needed
across the years, so I've always stuck with it when I need to write out to a
file.

--
Rick (MVP - Excel)


"Jacob Skaria" <(E-Mail Removed)> wrote in message
news:4FD88C29-BF00-4337-AA9C-(E-Mail Removed)...
> One more, you can also use...
>
> Write #1, cDataNoCrLf
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Francis Ang" wrote:
>
>> Thank you, Rick,
>>
>> It works! The semi-colon did the trick.
>>
>> Thank you.
>>
>> "Rick Rothstein" wrote:
>>
>> > Print statements put a CarriageReturn/LineFeed combination at the end
>> > of
>> > each line it prints by default. You can suppress this default
>> > functionality
>> > by placing a semi-colon at the end of the Print statement. Try it this
>> > way...
>> >
>> > Print #2, cDataNoCrLf;
>> >
>> > Notice the semi-colon at the end of the statement.
>> >
>> > --
>> > Rick (MVP - Excel)
>> >
>> >
>> > "Francis Ang" <(E-Mail Removed)> wrote in message
>> > news:848E7D5F-6EBD-4C9A-928F-(E-Mail Removed)...
>> > > Hi Joel,
>> > >
>> > > Thank you for responding so quickly. As requested, here is the code
>> > > I
>> > > wrote -
>> > >
>> > > Sub CarriageRmv()
>> > > Open "C:\abc.txt" For Input As #1
>> > > Do While Not EOF(1)
>> > > Line Input #1, cData
>> > >
>> > > cDataNoCrLf = Replace(cData, vbCrLf, "")
>> > >
>> > > Open "C:\NoCrLF.txt" For Append As #2
>> > > Print #2, cDataNoCrLf
>> > > Close #2
>> > >
>> > > If EOF(1) Then
>> > > Close #1
>> > > Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
>> > > Exit Sub
>> > > End If
>> > > Loop
>> > > End Sub
>> > >
>> > >
>> > > "joel" wrote:
>> > >
>> > >> I would like to see your code. Especially the way you are opening
>> > >> the
>> > >> file.
>> > >> thre are some defaults on how the file is being opened. You ca open
>> > >> the
>> > >> file
>> > >> as text or Unicode. You may be opening the file as unicode which
>> > >> really
>> > >> are
>> > >> 16 bit characters instead of 8 bit characters.I would also like to
>> > >> see
>> > >> your
>> > >> replace statement.
>> > >>
>> > >> "Francis Ang" wrote:
>> > >>
>> > >> > I am using REPLACE command to remove carriage return and line feed
>> > >> > from
>> > >> > a
>> > >> > text file; but when I rename the text file from 'abc.txt' to
>> > >> > 'abc.hex',
>> > >> > the
>> > >> > carriage return mysteriously reappears.
>> > >> >
>> > >> > I tried using the REPLACE command on 'abc.hex' file but it is not
>> > >> > working.
>> > >> > REPLACE seems to work on text file only.
>> > >> >
>> > >> > Any assistance will be greatly appreciated.
>> > >> >
>> > >> > Thank you.
>> > >> >
>> > >> >
>> >
>> >


 
Reply With Quote
 
Francis Ang
Guest
Posts: n/a
 
      3rd Apr 2009
Thank you Jacob for your response and also Rick for sharing your experience.


"Rick Rothstein" wrote:

> I believe using Write on the OP's text file will encase the entire file in
> quote marks. And, if the text contains quoted text within it, I believe
> there will be some problems around those embedded text strings also. I
> decided early on (maybe 25 years ago or so) to avoid using Write to put data
> into a file because of what I considered at the time to be some odd
> behaviors... in any event, I've found Print to do all I have ever needed
> across the years, so I've always stuck with it when I need to write out to a
> file.
>
> --
> Rick (MVP - Excel)
>
>
> "Jacob Skaria" <(E-Mail Removed)> wrote in message
> news:4FD88C29-BF00-4337-AA9C-(E-Mail Removed)...
> > One more, you can also use...
> >
> > Write #1, cDataNoCrLf
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Francis Ang" wrote:
> >
> >> Thank you, Rick,
> >>
> >> It works! The semi-colon did the trick.
> >>
> >> Thank you.
> >>
> >> "Rick Rothstein" wrote:
> >>
> >> > Print statements put a CarriageReturn/LineFeed combination at the end
> >> > of
> >> > each line it prints by default. You can suppress this default
> >> > functionality
> >> > by placing a semi-colon at the end of the Print statement. Try it this
> >> > way...
> >> >
> >> > Print #2, cDataNoCrLf;
> >> >
> >> > Notice the semi-colon at the end of the statement.
> >> >
> >> > --
> >> > Rick (MVP - Excel)
> >> >
> >> >
> >> > "Francis Ang" <(E-Mail Removed)> wrote in message
> >> > news:848E7D5F-6EBD-4C9A-928F-(E-Mail Removed)...
> >> > > Hi Joel,
> >> > >
> >> > > Thank you for responding so quickly. As requested, here is the code
> >> > > I
> >> > > wrote -
> >> > >
> >> > > Sub CarriageRmv()
> >> > > Open "C:\abc.txt" For Input As #1
> >> > > Do While Not EOF(1)
> >> > > Line Input #1, cData
> >> > >
> >> > > cDataNoCrLf = Replace(cData, vbCrLf, "")
> >> > >
> >> > > Open "C:\NoCrLF.txt" For Append As #2
> >> > > Print #2, cDataNoCrLf
> >> > > Close #2
> >> > >
> >> > > If EOF(1) Then
> >> > > Close #1
> >> > > Name "C:\NoCrLF.txt" As "C:\NoCrLf.hex"
> >> > > Exit Sub
> >> > > End If
> >> > > Loop
> >> > > End Sub
> >> > >
> >> > >
> >> > > "joel" wrote:
> >> > >
> >> > >> I would like to see your code. Especially the way you are opening
> >> > >> the
> >> > >> file.
> >> > >> thre are some defaults on how the file is being opened. You ca open
> >> > >> the
> >> > >> file
> >> > >> as text or Unicode. You may be opening the file as unicode which
> >> > >> really
> >> > >> are
> >> > >> 16 bit characters instead of 8 bit characters.I would also like to
> >> > >> see
> >> > >> your
> >> > >> replace statement.
> >> > >>
> >> > >> "Francis Ang" wrote:
> >> > >>
> >> > >> > I am using REPLACE command to remove carriage return and line feed
> >> > >> > from
> >> > >> > a
> >> > >> > text file; but when I rename the text file from 'abc.txt' to
> >> > >> > 'abc.hex',
> >> > >> > the
> >> > >> > carriage return mysteriously reappears.
> >> > >> >
> >> > >> > I tried using the REPLACE command on 'abc.hex' file but it is not
> >> > >> > working.
> >> > >> > REPLACE seems to work on text file only.
> >> > >> >
> >> > >> > Any assistance will be greatly appreciated.
> >> > >> >
> >> > >> > Thank you.
> >> > >> >
> >> > >> >
> >> >
> >> >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Carriage Return Rita Microsoft Access Reports 2 19th Nov 2008 01:56 PM
Adding a Hard Return or carriage return in an update query? Lakota2k Microsoft Access Queries 1 15th Sep 2008 04:56 AM
Carriage Return =?Utf-8?B?cHJvdWQyYmhhb2xl?= Microsoft Outlook Form Programming 0 28th Mar 2007 01:59 AM
carriage return Meg Microsoft Excel Discussion 2 5th Oct 2006 06:23 PM
Search and replace hard-line-return character, not carriage return =?Utf-8?B?VHlsZXIgVA==?= Microsoft Word Document Management 2 16th Aug 2006 09:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 AM.