boomer001
asked on
Filter a textfile
I'm rather new to vb6 and experience some problems on how to filter a textfile.
I have a text file wich I want to import in acces through vb.
This is not a problem, but before I want to import the text file I need to filter the text file.
What I want is to replace the fields containing a value of "120" with "E13" and replace the fields containing "sp001" with " " (nothing, just delete the value)
The textfile is comma seperated...
Thanks in advance
Best regards,
Boomer
I have a text file wich I want to import in acces through vb.
This is not a problem, but before I want to import the text file I need to filter the text file.
What I want is to replace the fields containing a value of "120" with "E13" and replace the fields containing "sp001" with " " (nothing, just delete the value)
The textfile is comma seperated...
Thanks in advance
Best regards,
Boomer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks!
Const TARGET As String = "c:\file2.txt"
Open SOURCE For Input As #1
Open TARGET For Output As #2
While Not EOF(1)
Line Input #1, MyLine
Print #2, Replace(Replace(MyLine, "120", "E13"), "sp001", "")
Wend
Close #2
Close #1