Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I love this site! It's so nice to know that there are so many people out there who are willing to share their knowledge..."

Geography

Where in the world do Tek-Tips members come from?
NickC111 (TechnicalUser)
9 Jul 12 10:47
Good Afternoon

I have a simple text document where I want to find and replace certain text.

**0915750600*CW3*STORE AND PREMISES*

I want to use find and replace - Find CW3 and replace with 970 - write a new file with the new changes

Any ideas?
jges (TechnicalUser)
9 Jul 12 10:57
Geates (Programmer)
9 Jul 12 11:44
Load the file in notepad. use find and replace (ctrl+h). save file :)

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer

NickC111 (TechnicalUser)
10 Jul 12 4:56
Thanks for the thread - I have come up with the following code

CODE -->

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Text.txt", ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "CH1", "*901*")

Set objFile = objFSO.OpenTextFile("C:\Text.txt", ForWriting)
objFile.WriteLine strNewText
objFile.Close 

Its finds "CH1" and replaces it with *901* in the test text file

I want to change the script so that its reads from a cross-reference and it finds a match enter the new data from the cross-reference table

Example

Test.txt

CH1
DR4
GH7
SX7
GE9
SP1

Cross-Reference Table

CH1 = *901*
DR4 = *856*
GH7 = *658*
SX7 = *025*
GE9 = *986*
SP1 = *756*

So the script reads the cross-reference where it finds a match in the text file it replaces it with the corresponding entry

Finds CH1 and replaces it with *901*

Any help would be great

Thanks







Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close