Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Merge Line by Line

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1198
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Merge Line by Line
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Merge Line by Line - 7/30/2004 5:37:17 AM   
  JohnStream

 

Posts: 1
Score: 0
Joined: 7/30/2004
From: USA
Status: offline
How do I merge two files together line by line?

Basically I want to shuffle two text files together.
 
 
Post #: 1
 
 Re: Merge Line by Line - 7/30/2004 7:37:40 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
I have never really used arrays before (Need to remedy that) but this is something that I threw together. It will only read 2 seperate arrays and pop out a message box for each line in the array but it is a start. If I have time this weekend I will look at it some more, just need to figure out how to write each line to a new file.

Mike

Const ForReading = 1, ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")

Set MyFile1 = fso.OpenTextFile("C:\File1.txt", ForReading)
Set MyFile2 = fso.OpenTextFile("C:\file2.txt", ForReading)
ReadMyFile1 = MyFile1.ReadAll
ReadMyFile2 = MyFile2.ReadAll

Array1 = Split(ReadMyFile1, vbcrlf)
Array2 = Split(ReadMyFile2, vbcrlf)

For j = 0 To UBound(Array1)
Msgbox Array1(j)
Next

For k = 0 To UBound(Array2)
Msgbox Array2(k)
Next

(in reply to JohnStream)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Merge Line by Line Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts