|
-
Nov 9th, 2004, 10:49 PM
#1
Thread Starter
Fanatic Member
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.
-
Nov 9th, 2004, 10:57 PM
#2
VB Code:
Dim strBuffer As String
Open "C:\SomeDir\MyFile.xml" For Binary Access Read As #1
Open "C:\SomeDir\OutFile.xml" For Binary Access Write As #2
strBuffer = Input(LOF(1), #1)
strBuffer = Replace$(strBuffer, "G:", "H:")
Put #2, strBuffer
Close #1
Close #2
"It's cold gin time again ..."
Check out my website here.
-
Nov 9th, 2004, 11:14 PM
#3
Thread Starter
Fanatic Member
Error on this line.......
I get a syntax error on this line.
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.
-
Nov 9th, 2004, 11:42 PM
#4
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.
-
Nov 9th, 2004, 11:50 PM
#5
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|