Solved

Need vbscript to compare text files

Posted on 2004-09-14
4
1,156 Views
Last Modified: 2012-06-27
I need a vbscript to compare a text file with a list of serial numbers as follows:

Textfile1
12345
23456
23457

and

Textfile2
12345
23456
etc...

If they are equal then exit
if they are Not equal then i will send and e-mail ( i have the e-mail script)

One list will be the constant, and the other will warn of changes.
0
Comment
Question by:chris_v
4 Comments
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 500 total points
ID: 12058414
how about a compare textfile function below
public function comparetextfile(byval srcfilename as string,byval desfilename as string) as bool
{
      Try
            ' Create an instance of StreamReader to read from a file.
            Dim srcsr As StreamReader = New StreamReader(srcfilename)
            Dim dessr As StreamReader = New StreamReader(desfilename)
            Dim linesrc As String,linedes as string
            Do
                linesrc = sr.ReadLine()
                linedes=sr.readline()
                if(linesrc!=linedes) Exit do
            Loop Until linesrc Is Nothing or linedes is nothing
            srcsr.close()
            dessr.Close()
            if(linesrc is nothing and linedes is nothing) return true;
            return false;
        Catch E As Exception
            ' Let the user know what went wrong.
            Console.WriteLine("The file could not be read:")
            Console.WriteLine(E.Message)
        End Try
        return false
}
0
 
LVL 2

Author Comment

by:chris_v
ID: 12059992
Found another solution..  thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
debug as  junit test 4 80
can finally block executed even when there is a return statement in try block 4 80
canBalance challenge 34 80
Adjust the position 3 60
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now