count elements in an array

T

thomasp

If I have an array declared as Dim aryTargets(99) as integer, can I get the
count of how many of the elements actually are filled without looping
through the array and testing the value of each element of the array?

Thanks,

Thomas
 
H

Herfried K. Wagner [MVP]

If I have an array declared as Dim aryTargets(99) as integer, can I get
the
count of how many of the elements actually are filled without looping
through the array and testing the value of each element of the array?

Yep, the array doesn't provide a built-in mechanism to check how many items
(don't) have a certain value.
 
C

Cor Ligthert [MVP]

Thomas,
If I have an array declared as Dim aryTargets(99) as integer, can I get
the
count of how many of the elements actually are filled without looping
through the array and testing the value of each element of the array?
Why do you use a fixed array if it is not completely filled. Is than an
arraylist a better choice

Just a thought,

Cor
 
T

thomasp

I don't know the difference, but I will read up on the two. An arraylist
may be the better choice for me.

Thanks,

Thomas
 

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

Top