Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to modify Text file

Status
Not open for further replies.

nat1967

Technical User
Feb 13, 2001
287
US
Hi Everyone,

I need to modify a whole bunch of text (.txt) files and just cant seem to pull together the code to do this.

The current text file has a single line with information like:

<CLEC_USER_ID/> <TRX_NAME/> <TXNUM/>

What I want to do is open the text file and after each one of the > symbols, I would like to have a carriage return added and then move to the next file.

It should end up like:

<CLEC_USER_ID/>
<TRX_NAME/>
<TXNUM/>

Any help is greatly appreciated.

TIA

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
I have found that using a good Word processing software such as MS Word is the best way to do this. By using the Find and Replace option of the Edit menu you can search for > and replace it with a > and the carriage return mark.

This works quite well.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Hi Bob,

I agree and that was my approach. Unfortuately for me, there are 200+ files. I was just thinking there would be an easier way. I have played around with some code but text files always give me a fit.

Thanks for the suggestion.

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
I don't if this helps but I have a Function that can be called to Find and Replace characters in a string. Maybe you can figure out how to use it in your situation.

Public Function ReplaceEmbedded(CharToReplace As String, SearchString As String, ReplacementChar As String)
Dim i As Integer, s As String, ss As Integer
ss = Len(SearchString)
s = &quot;&quot;
For i = 1 To ss
If InStr(CharToReplace, Mid$(SearchString, i, 1)) = 0 Then
s = s & Mid$(SearchString, i, 1)
Else
s = s & ReplacementChar
i = i + (Len(CharToReplace) - 1)
End If
Next i
ReplaceEmbedded = s
End Function


Let me know if I can be further assistance.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Thanks again,

Actually, I just figured out what I needed. I have used some code before using SearchReplace and tweaked it for what I needed.

Thanks again for all your help and suggestions. I was getting frustrated and you helped me re-focus.



Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top