Merge Two Files

A small example of how to merge 2 files together.

Example

x=Join("C:\Test1.txt", "C:\Test2.txt")
Msgbox "Joined Successfully. NewSize of test2.txt is"+str$(x)

Function Join(strFile1 As String, strFile2 As String) As Long
    Dim b() As Byte
    Dim nFileNum As Integer
    Dim lFileLen As Long

    nFileNum = FreeFile
    Open strFile1 For Binary Access Read As nFileNum
        b() = InputB(LOF(nFileNum), nFileNum)
    Close nFileNum

    nFileNum = FreeFile
    lFileLen = FileLen(strFile2)
    Open strFile2 For Binary Access Write As nFileNum
        Put nFileNum, (lFileLen+1), b()
    Close nFileNum
   
    Join = lFileLen
End Function

You might also like...

Comments

Kym Manson Till the Roof comes off Till the Lights go out Till my Legs give out Can't shut my mouth I will not fall, my Wisdoms all.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”