Solved

Need vbscript to compare text files

Posted on 2004-09-14
4
1,159 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

733 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