Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Append files using VB6

Posted on 2002-07-25
3
Medium Priority
?
1,198 Views
Last Modified: 2007-11-27
My VB6 program reads one source text file and distributes its records to a number of output text files.  The amount and count totals for each output file are computed during this distribution process.

The totals need to be included in batch header records and the files appended together thus.  :  Batch header record + file + batch header record + file etc.

Can this be done with VB6 code without having to read and write individual records from one file to another?

Is there a Windows command that the program can call that will append one text file to another?

0
Comment
Question by:msdav
3 Comments
 
LVL 10

Expert Comment

by:aeklund
ID: 7178247
You can Shell out the "COPY" command, which is one way to do it..

example:

shell "copy " & file + file + file outputfile

The only other way that I know of is to read the contents of each file into variables, then write the entire thing out into your output file.
0
 
LVL 2

Accepted Solution

by:
damion69 earned 800 total points
ID: 7178248
you can append 1 file to another like this. I am currently using it as a trial version proggie for my software. It is designed to append to an exe but will work with any format. I got this code off of www.planetsourcecode.com not sure of the author or i would give him credit.

Private Sub AppendToExe(exefile$, filetoappend$)
Dim f As Integer
    Open filetoappend$ For Binary As #1
    filedata$ = String(LOF(1), " ")
    Get #1, , filedata$
    Close #1
    Open exefile$ For Binary As #1
    f = LOF(1)
    Seek #1, f + 1
    Put #1, , "treg" 'Change the identifier here
    Put #1, , filedata$
    Close #1
End Sub

Private Sub ExtractFromExe(exefile$)
    Open exefile$ For Binary As #1
    filedata$ = String(LOF(1), " ")
    Get #1, , filedata$
    Close #1
    pos = InStr(1, filedata$, "treg")'change identifier
    f$ = Mid$(filedata$, pos + 4) '+the len(identifier)
    MsgBox f$
End Sub
0
 

Author Comment

by:msdav
ID: 7178369
damion69 answers allows for both file copy and insertion of batch header record information as the "treg" variable - interesting solution!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question