Carriage Return => Tab 
Author Message
 Carriage Return => Tab

I am trying to go through a text file and replace all carriage returns
with tab (in VBA).
This is what I am doing:
open file,
while not EOF
        read line input as string
        if Asc(Right(string)) = ASCII code for carriage return (its 13)
then
                make Right(string) = Chr(ASCII code of tab [its 9])
        end if
loop

the problem is, that when it reads the line in, it omits the carriage
return at the end of the line (as expected).

can anyone help me do this, or know of a better solution.

Thanks,
sAwt



Sun, 13 Jan 2002 03:00:00 GMT  
 Carriage Return => Tab
If I'm not mistaken, Line Input reads up to the first CR/LF, so you won't
find it with the Asc(Right(string))
if statement...

for lack of a better idea, you could open the file as binary, and use the
Get statement to retrieve one byte at a time, then the put statement to
replace any byte positions found to have Chr(13)'s with Chr(9)

Quote:

>I am trying to go through a text file and replace all carriage returns
>with tab (in VBA).
>This is what I am doing:
>open file,
>while not EOF
>        read line input as string
>        if Asc(Right(string)) = ASCII code for carriage return (its 13)
>then
>                make Right(string) = Chr(ASCII code of tab [its 9])
>        end if
>loop

>the problem is, that when it reads the line in, it omits the carriage
>return at the end of the line (as expected).

>can anyone help me do this, or know of a better solution.

>Thanks,
>sAwt



Sun, 13 Jan 2002 03:00:00 GMT  
 Carriage Return => Tab
Use the Mid function to check the character after the value. If it's a line
feed don't make the change.

Quote:
> I am trying to go through a text file and replace all carriage returns
> with tab (in VBA).
> This is what I am doing:
> open file,
> while not EOF
>         read line input as string
>         if Asc(Right(string)) = ASCII code for carriage return (its 13)
> then
>                 make Right(string) = Chr(ASCII code of tab [its 9])
>         end if
> loop

> the problem is, that when it reads the line in, it omits the carriage
> return at the end of the line (as expected).

> can anyone help me do this, or know of a better solution.

> Thanks,
> sAwt



Sun, 13 Jan 2002 03:00:00 GMT  
 Carriage Return => Tab
Stephen Locke is on the right track.  The CR/LF will drop off on a LINE INPUT.  The trick is to add your Chr(9) but avoid the CR/LF
when your write the data back out.

Use Print #1, strData & Chr(9);

The semicolon will supress the CR/LF of the Print statement.

ps: I think you should have posted to microsoft.public.access.externaldata

Steve



Sun, 13 Jan 2002 03:00:00 GMT  
 Carriage Return => Tab
Thanks Steve, I'll try that. sorry about the posts to the wrong NG, I
didn't know microsoft.public.access.externaldata existed. It would have
made more sense.
Sawt
Quote:

> Stephen Locke is on the right track.  The CR/LF will drop off on a LINE INPUT.  The trick is to add your Chr(9) but avoid the CR/LF
> when your write the data back out.

> Use Print #1, strData & Chr(9);

> The semicolon will supress the CR/LF of the Print statement.

> ps: I think you should have posted to microsoft.public.access.externaldata

> Steve



Sun, 13 Jan 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Carriage Return => Tab

2. REG files don't merge TAB and carriage returns

3. Displaying Carriage Returns and Tabs

4. REG files don't merge TAB and carriage returns

5. REG files don't merge TAB and carriage returns

6. ---> How to force a Carriage return

7. >>>> Tab Key --- Please Help

8. Put a carriage return in text

9. Carriage Return in SQL Statement

10. Carriage Returns In Text Boxes

11. carriage return in a report textbox

12. Deleting Last Carriage Return from Text File

 

 
Powered by phpBB® Forum Software