Solved

Append files using VB6

Posted on 2002-07-25
3
1,182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 9 hours left to enroll

634 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