Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

invoke 2 sub function simultaneouly (files comparison)

Posted on 2001-06-26
11
Medium Priority
?
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +5
11 Comments
 
LVL 28

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 28

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Accepted Solution

by:
rspahitz earned 400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 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