adding text to a file or patch

RCILL
RCILL used Ask the Experts™
on
HI,
I am new to VB6. Is there a way i can add some text to a file on command? Like patch a file?

The file looks something like this:

on_group(5)
{
        load_ocm        advert      
}
on_group(11)
{
        load_ocm        advert      
}

What I want to do is, add a semi colon in front of both load_ocm  like this:

on_group(5)
{
        ;load_ocm        advert       required
}
on_group(11)
{
        ;load_ocm        advert       required
}

How would I make a command to do this?
  Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Here you go:

   Dim MyFile As String
   Dim lFreefile As Long
   lFreefile = FreeFile
   
   'Open the original file
   Open "c:\MyFilePatch.txt" For Input As #lFreefile  'Opens The File And Names It #1
   
   MyFile = Input$(LOF(lFreefile), lFreefile)   'Assigns The Text In The File To MyFileText
   Close #lFreefile

   'Now replace all occurances of "load_ocm" with ";load_ocm"
   MyFile = Replace(MyFile, "load_ocm", ";load_ocm")
 
   'Re-open the same file for output
   lFreefile = FreeFile
   Open "c:\MyFilePatch.txt" For Output As #lFreefile
   'Put it in there.
   Print #lFreefile, MyFile
   Close lFreefile

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial