PDA

View Full Version : Find and Replace ? (NET)



g707
04-23-2004, 10:16 AM
Here what I'd like to do in VB Script:
1) Read a file = C:\file.log
2) Replace/reformat every instance a partial string.
*Example:
Replace
"04/01/2004 12:00:00.001"
with
"04/01/2004","12:00:00.001"

I could just replace all instances will of:
'/2004 ' with '/2004","' - (single quotes are shown to display blank)
Using the Replace(), but I am having some problems reading the file when using replace().

Probably just syntax can anyone help?

Also, The strings appear in the same spot on every line, could I also use the mid function? Which method would be better?

This seems simple enough, but I can't get the syntax right.

Any help would be greatly appreciated.

Thanks,

*******
* g707 *
*******

dineshcooper
05-07-2004, 03:09 AM
Hi

The code below reads in each line and does the replace, you will just have to modify the code so that you write back to the file.

do while false = oFile.AtEndOfStream
strData = oFile.Readline()
MsgBox(Replace(strData,"/2004", "/2004"","""))
Loop


Hope that helps
Cheers
Dinesh