Log in

View Full Version : Copy Text file character by character to another file



vijaysoni
06-27-2013, 08:58 PM
Hello All,

I have below requirements. Can any one help me?

1. I have to write a program which will copy a text file data character by character into new text file.
2. Whenever it finds a particular string "0000" it will have a separate logic which will decode the text after this string. we have code for this logic.
3. Above decode information will be placed in the new text file.
4. This will continue till end of file.


Thanks

HiTechCoach
06-29-2013, 09:47 AM
This should get you started:




Dim FH As Integer
Dim FH2 As Integer
Dim strPath As String
Dim strPathOut As String
Dim strLineIn As String
Dim strLineOut As String

strPath = "c:\myfiles\data_in.txt"
strPathOut = "c:\myfiles\data_out.txt"


FH = FreeFile

Open strPath For Input As #FH

FH2 = FreeFile

Open strPathOut For Output As #FH2

Do
Line Input #FH, strLineIn

' convert LF to CR + LF
strLineOut = Replace(strLineIn, Chr(10), vbCrLf)


Print #FH2, strLineOut


Loop Until EOF(FH)

Close #FH
Close #FH2