i have two text file(output.txt,sampleExtract.txt), i want combine the content of that two file to became one new file.How to do it?
Printable View
i have two text file(output.txt,sampleExtract.txt), i want combine the content of that two file to became one new file.How to do it?
You can do something like this:
Code:Private Sub CombineFiles(filein1 As String, filein2 As String, fileout As String,)
Dim sText1$, sText2$
Open filein1 For Input As #1
sText1 = Input(LOF(1), #1)
Close #1
Open filein2 For Input As #1
sText2 = Input(LOF(1), #1)
Close #1
Open fileout For Output As #1
Print #1, sText1
Print #1, sText2
Close #1
End Sub
DOS has the COPY command to do just that. So you can do it thru code (as RhinoBull suggested) or shell to that command.
The command is:
Copy file1+file2 File3
Are you in taking the same course as this guy...
http://www.vbforums.com/showthread.php?t=460249
it has an extra blank line on the end of "Output.txt"Quote:
Originally Posted by RhinoBull
how to remove the blank line?
aren't you going to do any of the HW yourself???
What do you mean by "extra"? The last 2 characters in the file are vbCR and vbLF, because the last thing done to the file was to print a line. If you want to eliminate that line, change Print #1, sText2 to Print #1, sText2;Quote:
Originally Posted by junlo
If there are 2 blank lines at the end, it's because there's an extra line at the end of the second file. Remove any occurrences of vbNewLine & vbNewLine (two of them in a row) from the end of sText2 before you print it to the output file.