Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


search and replace help

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,53436
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> search and replace help
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 search and replace help - 11/10/2007 8:01:03 PM   
  buffi

 

Posts: 87
Score: 0
Joined: 3/28/2005
From:
Status: offline
Hi All,
I am trying to create a script that search for a specific string and change a part of it.
The "vmware-domain" should be a wild card name and not the name that exists.
The purpose of this script is to find the old domain and change it to the new one.
I have copied and pasted some old cript that i have but i have trouble getting this one to work as i suck in VB :(
Would really appreciate your help


      

Regards,
Buff

CrazyMAtt Edit: Fixed the code tags..

< Message edited by crazymatt -- 11/12/2007 1:45:25 AM >
 
 
Post #: 1
 
 RE: search and replace help - 11/11/2007 7:12:46 AM   
  morpheus83uk

 

Posts: 435
Score: 0
Joined: 8/21/2006
Status: offline
Hello,


I have had a look at your code and put into something a little more manageable... well for me anyways lol :)


      

Firstly you missed out the End If on your If Statement and you will get an error on the following line:

strText = objFileR.ReadAll

As there is nothing in the text file so it cant read it and will get some sort of End Of File error.

You would need to write something to the text file first before it can be read. What is the text file for?

Many Thanks

James


(in reply to buffi)
 
 
Post #: 2
 
 RE: search and replace help - 11/13/2007 2:19:43 AM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi buffi,

if changing

strNewText = Replace(strText, "srtOldDomain", "strNewDomain")

to

strNewText = Replace(strText, strOldDomain, strNewDomain )

doesn't help, post your parameters.txt file.

Hi morpheus83uk,

please test your code before posting. You are using "Option Explicit",
but don't Dim all variables (e.g. objFSO); opening the same file twice
isn't a good idea either; you should have caught the wrong quotes
in the Replace call.

Regards

ehvbs

(in reply to buffi)
 
 
Post #: 3
 
 RE: search and replace help - 11/13/2007 9:11:26 AM   
  morpheus83uk

 

Posts: 435
Score: 0
Joined: 8/21/2006
Status: offline
Hi,

Thanks for that I thought I did dim everything must have missed one or two.

I think I was looking at it a little more complicated before I posted so I got a little confused but well at least someone spotted the quotes.

Thanks

James

(in reply to ehvbs)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> search and replace help Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts