Results 1 to 3 of 3

Thread: Need help with Collections

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 1999
    Posts
    17

    Post

    I posted a question a week ago about comparing 2 huge lists and getting the difference. One of the suggestions was to use a Collection. It worked and it was 20 times faster than what I had. The problem is that it only finds 8 matches when there are about 10,000 matches. The lists are file name with paths:

    c:\autoexec.bat
    c:\winnt\calc.exe
    ...

    The matches that it finds are in the root directory ( c:\autoexec.bat , c:\config.sys and so on) Once it hits subfolders it fails to find a match. I did an LCase() on the variable before I add it to the collection. And I did the same to the variable to be compared. So all the data is in lower case. Yet it still can't find all the matches. Here are some snippets from the program:

    Public OrjFN As New Collection
    .
    .
    .
    Open "c:\OrjNT.txt" For Input As #1
    Line Input #1, A$
    A$ = LCase$(A$)
    OrjFN.Add A$, A$
    Close #1
    .
    .
    .
    Open "c:\lclfil.txt" For Input As #1
    Do
    Fnd = 0
    Line Input #1, TmpFN
    TmpFN = LCase$(TmpFN)
    sDummy = OrjFN.Item(TmpFN)
    bFound = (Err = 0) 'Err=0 when item found in collection
    If bFound Then
    Err.Clear
    Fnd = 1
    End If
    If Fnd = 0 Then 'not foud so add it to the list
    ServerF.AddItem (TmpFN)
    End If
    Loop Until EOF(1)
    Close #1


    I tried to output the contents of the collection to a file, and it was correct.

    Am I doing something wrong here?
    Is there a limit on the length of the string that can be added to the collection?



    ------------------
    Joe Handal
    Workstation Engineer
    [email protected]

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    I don't know what the problem is except to suggest that you should explicitly Dim all your variables if you have not already done so. Also I just created a collection that contained a 300+ character string variable and was able to find it when I looked for it by the same key. If you want to send me your code (and sample data files), I'll take a look at it when I get a chance.

    ------------------
    Marty
    Can you buy an entire chess set in a pawn shop?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 1999
    Posts
    17

    Post

    Found the problem. Instead of checking the error number, I checked if sDummy = TmpFN, and that fixed it.

    Thanks

    ------------------
    Joe Handal
    Workstation Engineer
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width