Re: Appending text files

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rick Rothstein (rickNOSPAMnews_at_NOSPAMcomcast.net)
Date: 06/09/04


Date: Wed, 9 Jun 2004 10:04:21 -0400


> > Does anyone know how to append text files using VB? I am outputting
three
> text files from SQL Server using DTS. The first file contains header
data,
> the second contains the base data and the third contains trailer data.
I
> need to be able to append the header data at the beginning of the base
data
> and the trailed data on the end. I've never appended text files
before and
> would really appreciate some help. I am using VB6 and SQL Server 2000
on an
> NT4 box.
>
> Here's one way:
>
> When you call the JoinFiles subroutine you must pass it an array of
files to
> join. The array can contain one or more filenames. You also pass it
the name
> of an output file which will receive the joined contents.
>
> Example:
>
> Call JoinFiles(Array("File1.txt", "File2.txt", "File3.txt"),
"File123.txt")
>
> (joins File1.txt, File2.txt and File3.txt, outputs result to
File123.txt)
>
> '----------
> ' Joins two or more files
> ' Note: First parameter expected to be an array of filenames
> Sub JoinFiles(sFiles As Variant, sFileNew As String)

I probably would have declared your Sub this way instead

Sub JoinFiles(sFileNew As String, ParamArray sFiles() As Variant)

and dispensed with the need to (remember to) pass an Array function into
the Sub. (Nothing in your code needs to be changed to accommodate this
suggestion.)

Rick - MVP



Relevant Pages

  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Multiple OUs?
    ... something is up with adding multiple values to the array... ... ' If the AD enumeration runs into an OU object, call the Sub again to ... strLine = Trim ... strNewContents = strNewContents & strLine & vbCrLf ...
    (microsoft.public.scripting.vbscript)
  • Re: Packages and returning errors
    ... > array intact. ... sub is_a_instance_method { ... my $class = shift; ... You need to fix the scope of $error by moving its declaration outside ...
    (comp.lang.perl.misc)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreMyOldVals ... ' store values of current row in array ... Dim dbs As DAO.Database, rst As DAO.Recordset ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)