Solved

invoke 2 sub function simultaneouly (files comparison)

Posted on 2001-06-26
11
165 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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
 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

773 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