|
Home > Archive > MCSD > May 2002 > Problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| TW2001 2002-05-23, 1:52 pm |
| I have a report that is compared once a month.Its an offsite tape rpt.We audit our library and compare that with an offsite list.I usually strip the attachment,FTP the file(s) to a unix box and run a diff on them and create another file with any discrepencies.
I want to develop a VB solution to
a)compare the files
b)generate the differences
c)create a formatted report (im going to use flags for certain categories..eg 1= frozen volume.
I just want to make a user friendly app.
What ive been doing is..
reading the files into two dynamic arrays
(the format of the file is
SS1200
SS1201
DF2300
DF2301..etc)
then comparing elements one buy one..
If vol(0,0) = vol1(0,0) then...
I should proably loop this(the file(s) have over 3000 entries..
I did a small VBA app to compare spreadsheets with these files imported.It worked OK.VBA is to limited as I want to build a lot more functionality into my application(email,reports,List
box filled with the errors)
I guess Im looking for another perspective or maybe someone has worked on a similar project.
Thanks | |
| fmusick 2002-05-24, 2:34 pm |
| I can think of two solutions. The first would be opening the two as text files and then doing a similar compare to the one you mentioned, maybe using a string Split to parse out the array.
The second is using the Jet provider and treating the text files as ISAM sources. It should let you use a simple SELECT statement to create a recordset with only the differences (either with a where clause or a join) and you can do what you want with it. The link below contains the connection strings for accessing text files.
http://support.microsoft.com/defaul...b;EN-US;q262537
The array would be simpler to code and debug but it may be slow with 3000 lines. You can use the UBound(arrayname) statement for iteration of the loop. | |
| TW2001 2002-05-25, 6:47 am |
| Thanks for the response fmusick.
Could you elaborate on the string split parsing suggestion?
As far as the other idea.That sounds good.Honestly I will need to read up a little more on that approach though.
Thanks again. | |
| fmusick 2002-05-25, 10:54 am |
| Sure. A few years ago, VBScript added Regular Expression functions. They were incorporated into VB6. In this case, Split takes a string and a delimiter (great if you have to deal with the carriage retutn/line feed differences between windows and everyone else ). There's also optional arguments for limit and compare type. The syntax is this:
array = Split(string, delimiter, limit, compare method)
You can then run a loop like this:
For i = 0 to UBound(array)
array(0)...
As for getting the string, there's an OpenTextFile statement for the FileSystemObject. It's syntax is:
[text stream] = fso. OpenTextFile(filename,ForReadi
ng)
string = [text stream].ReadAll
You can also use an Open statement first and then use a Get statement. The syntax would be something like:
Open for Input Access Read As #filenumber
Get(#filenumber, string)
You can also use it for binary reading by changing the "Input" to "Binary" and the string to a Byte array. |
|
|
|
|