Question Locked

Large collection in VB6

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi

I have a program that implements the following structure

Each file has a collection of record
Each record has a collection of fields
Each Field has a collection of errors

When I run the program on a file with 20,0000 records of 58 fields (with a trivial number of errors) it takes for ever (5 minutes) to set the record collection to Nothing (explicitly or by using the END statement)

Can anyone suggest how I can overcome this issue?

Thanks

4 replies

by jck

Ditch collections. They are horribly slow.

I'd suggest making a recordset and working in memory with those.

by slayer_

Which, although are a tad slower when you get into the larger sizes, are still faster than collections.

For better performance, use increments, I usually use increments of 10 or 100, depending on the scale of the array.

Then using such an array is easy. i usually make a function or a class to handle it.

Dim dCount as double
dim aValues() as string
public Sub AddToArray(sValue as string)
if dCount = ubound(aValues()) then
redim preserve aValues(0 to dCount + 10)
end if
avalues(dCount+1) = sValue
dCount = dCount + 1
end sub

And thats the function to create a dynamic array. You can add a function to also initialize the array.

This discussion is closed to new replies.