Am I likely to cause an error?

R

Rob Meade

Hi all,

I have some code which compares values in a recordset to that in an array.

If it finds a match it needs to remove the item from the array.

My concern is that my method for removing the item from the array is by
iterating through it, if it doesn't match then I place the value into a
"temporary" array, after all comparisions are completed I then set the
original array to equal the temporary array.

Am I likely to generate an error if my internal looping of the same array
changes the array size, whilst still iterating through it..

eg..

For x = 0 to ....

if comparision is true then

for y = 0 to ....

if comparision is false then

' add value to temporary array here

end if

next

array = temporary array

end if

Next

My feeling is that this will go mammories up...

Regards

Rob
 
C

CJM

Am I likely to generate an error

Hopefully.. it's what development is all about...!
if my internal looping of the same array changes the array size, whilst
still iterating through it..

OIC. Yes definitely. At least I think so, give the little that you have told
us.

If you are intent on looping through your initial array, and you mean to
selectively remove items from it, whilst continually updating it, then yes
you will invoke an error... At some point your original array will shrink
and your loop will try to query an item that no longers exists - when x = a
value greater than the UBound of your modified array.
My feeling is that this will go mammories up...

Same here.

More importantly, I dont think your overall approach is right, but it's
difficult to tell without a bit more context. What are actually trying to
achieve?

Regardless, I wouldnt recommend modify your initial array until you have
completely looped through it.

CJM
 
R

Rob Meade

...
Same here.

Cheers for the confirmation...
More importantly, I dont think your overall approach is right, but it's
difficult to tell without a bit more context. What are actually trying to
achieve?

It's a rather long winded explanation so I'll not trouble you with it - as I
think I'm about there now, but just needed to check this as I guessed a
different approach would be needed..

Thanks :eek:)

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top