Solved

Need vbscript to compare text files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

919 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

17 Experts available now in Live!

Get 1:1 Help Now