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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to search several .vbp file containing server name

Status
Not open for further replies.

pcpro

MIS
Feb 24, 2001
15
US
Newbie here..

I have taken over a project were we are going to be changing a server name on the network and we have over 200 vbp files to search for this server name as it could be hardcoded in to any of these vbp files.

1. Why are we changing the server name. Well we are installing a new server to replace the old and we want to run parallel until the project is complete.
2. Why is the server name hardcode in the program? I don't know I did not write the programs.
3. I have tried Search for Files and Folder using the containing text but no luck or I am using it wrong.

So if you can help me find an easier way to search the file I would apprecate it.
 
Are you sure its in the vbp files? They contain only the paths to components used in the program ... not the program code. Try searching in files with *.frm (forms), *.bas (modules), *.cls (classes), *.ctl (user control) extensions.
 
One option would be using the Microsoft Visual Basic 6.0 Extensibility library. This lets you create an Add-In for the VB IDE and you can do things like manipulating code. I wrote an Add-In a few years back that inserted code into modules depending on certain criteria, and deleted certain lines of code throughout a project. Your code would be similar, but instead of Search & Delete yours would be Search & Replace.

An easier option: since forms and modules are just text files, you could just write a little program that opens these files one at a time, reads in one line at a time, replaces the old string (if it is there) with the new string, and rebuilds the file.
 
Agent Ransack / Windows Grep should help with searching. I've just used both to correct a misspelled (and very common) word across a large project.

HTH

TazUk

[pc] Blue-screening PCs since 1998
 
While I'm quite sure I'm preaching to the converted here, pcpro, this is a situation that cries out for refactoring. You might consider creating an object that has the server name in it, and having a GetServer method or whatever that gets called by any place that currently hardcodes the server. This probably wouldn't require a whole lot more development overhead than the job you currently have at hand.

Bob
 

What I would do - I would create a Project Group out of all of the 200 projects (well, maybe 15-20 at the time) and use MZTools (the price is right :) to look for the server and replace it.

HTH

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top