Solved

Append files using VB6

Posted on 2002-07-25
3
1,174 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

740 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