Results 1 to 5 of 5

Thread: Is this possible? Find & Replace

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Resolved Is this possible? Find & Replace

    I need to write a small app that will read through the text in a file, and every time "G:" is found, I want to replace those 2 characters with "H:". Basically, I need to do this with out modifying the file in any other way. The file is a .XML file, but all I'm looking for is occurences of "G:". Any help appreciated.

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    VB Code:
    1. Dim strBuffer              As String
    2.  
    3.     Open "C:\SomeDir\MyFile.xml" For Binary Access Read As #1
    4.     Open "C:\SomeDir\OutFile.xml" For Binary Access Write As #2
    5.  
    6.     strBuffer = Input(LOF(1), #1)
    7.     strBuffer = Replace$(strBuffer, "G:", "H:")
    8.     Put #2, strBuffer
    9.     Close #1
    10.     Close #2
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Error on this line.......

    I get a syntax error on this line.

    Code:
    Put #2, strBuffer

    Thanks for the help btw, I need to brush up on my VB. I graduate from college in 4 weeks and VB was the one programming class I was pretty good at. Hated COBOL!
    Last edited by hipopony66; Nov 9th, 2004 at 11:20 PM.

  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Sorry, missed a comma. Should be:
    Put #2, , strBuffer

    BTW, not to show my age or anything, but when I first started in this field, COBOL was the hot language ...
    "It's cold gin time again ..."

    Check out my website here.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Thanks........

    I just figured that out by searching through some other posts. The bytenumber to start writing at would normally go between those commas. Thanks again, this was a mini project to fix my iTunes music library after moving files around during a HDD upgrade. I've found more small uses for VB!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width