Solved

invoke 2 sub function simultaneouly (files comparison)

Posted on 2001-06-26
11
162 Views
Last Modified: 2010-05-02
I have C:\software and D:\software
Now i knew that some files name inside the D:\software is not same
with D:\softare
So i need to do file comparison between C:\softare\*.* and D:\software\*.*

Now i need to invoke 2 function call simultaneouly, 1 function to check
C:\software\ and another to check D:\software\  , then it will detect if any files in D:\
not the same with C:\

I need help on how to invoke 2 sub function simultaneouly !
( i am using 'for each f1 in fso.......next' method to go through the files
1 by 1)
0
Comment
Question by:changchyi
  • 2
  • 2
  • 2
  • +5
11 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 6230609
You can store results in array, collection, listbox etc and compare them after enumeration.
Or during enumeration you can replace first path ("c:\software") with second "d:\software" and check with dir if file exist.

Cheers
0
 
LVL 27

Expert Comment

by:Ark
ID: 6230622
Or
Set fld1 = FSO.GetFolder("c:\software")
Set fld2= FSO.GetFolder("d\software")

For i = 1 to fld1.Files.count
    fil1 = fld1.Files.Item(i)
    fil2 = fld2.Files.Item(i)
next i

Cheers
0
 
LVL 4

Expert Comment

by:chabaud
ID: 6231089
You could also try the WinDiff utility...
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 6233246
You can build a list of both, alphabetically, then compare.

Two ways

#1:

dim strArrayOfDriveC() as string
dim strArrayOfDriveD() as string
dim strFileName as string
dim intFileCntr as integer
'
intFileCntr=0
strFileName = dir$("C:\software\*.*")
while strFileName <>""
  redim strArrayOfDriveC(intFileCntr)
  strArrayOfDriveC(intFileCntr) = strFileName
  intFileCntr = intFileCntr + 1
wend
' Call routine to sort this

intFileCntr=0
strFileName = dir$("D:\software\*.*")
while strFileName <>""
  redim strArrayOfDriveD(intFileCntr)
  strArrayOfDriveD(intFileCntr) = strFileName
  intFileCntr = intFileCntr + 1
wend
' Call routine to sort this

' Call routine to compare each array element.  On mismatch, you've found a difference.

---
#2:

dim strCFileName as string
dim strDFileName as string

shell("command /c dir c:\softare /b /on > C:\Temp\CFiles.txt")
shell("command /c dir d:\softare /b /on > C:\Temp\DFiles.txt")

open "C:\Temp\CFiles.txt" for input as #1
open "D:\Temp\DFiles.txt" for input as #2

while not eof(1) and not eof(2)
  line input #1, strCFileName
  line input #2, strDFileName
  if strCFileName <> strDFileName then
    ' mismatch
  endif
wend

if not eof(1) or not eof(2) then
  ' extra file found on one or the other
endif

close #2
close #1
0
 
LVL 5

Expert Comment

by:Leithauser
ID: 6240160
If you want the file lists of two folders simulatiously, you can put two FileListBoxes on a form. Set the path of one FileListBox to one of the folders and the other FileListBox to the other folder. Then you can compare the two lists you get using the List function, something like

If File1.ListCount <>  File1.ListCount Then
   (code for not even the same number of files)
End If

For X = 1 to File1.ListCount
   If File1.List(X)<>File2.List(X) Then
      (code for files not the same here)
   End If
Next X
0
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.

 
LVL 5

Expert Comment

by:Leithauser
ID: 6240626
Comment on my own answer:

   I made a small mistake in typing in the answer. Because the FileListBox control numbers its contents starting from 0, the For statement should read

For X = 0 to File1.ListCount-1

Otherwise, you do not get a comparison on the first file in the list. (Oddly enough, you do not get a crash when trying to read the nonexistant item at the end.) Sorry about the mistake.


 
0
 

Expert Comment

by:abhi_panickar
ID: 6242759
well if u want to use both the functions at the same time...then u would have to use multithreading.. which i dont know how it is done explicilty tru vb... but i certainly know how to do it using api calls in combination with the addressof operator...
this allows both the functions to run at the same time on independent threads

i hope this helps u..need more info.....i am listening...



Metallika Rulz!!
0
 

Expert Comment

by:costello
ID: 6400376
Rejecting proposed answer.

Experts, please provide feedback on which comment should be graded here.

costello
Community Support Moderator @ Experts-Exchange
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6429098
I would probably go with Ark's 2nd comment, or my 1st comment.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7139850
Hi changchyi,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept rspahitz's comment(s) as an answer.

changchyi, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7178873
Comment from expert accepted as answer

Computer101
E-E Moderator
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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 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

10 Experts available now in Live!

Get 1:1 Help Now