• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1221
  • Last Modified:

Are VB6 custom collections zero-based or one-based???

Hi gang,

I'm working on a VB6 legacy app at my client and I haven't touched VB6 in about 9 years. I am using a custom collection to store instances of a custom object I created. I had no problem adding objects to the collection. My question is, when referring to one of n objects in the collection,  are the positions 1-to-n (one to n) or 0-to-(n-1). They appear to be one-based because I am getting subscript out of range errors, but I thought I would run it by you guys to find out if I am missing something.

Best regards,
  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
use lbound(  array ) and ubound( array )
for collections, they are 1-based.
KMcElhineyAuthor Commented:
Thanks for the reply. I found another reference that says that VB6 collections are indeed one-based:
However, collections are not arrays and do not support the ubound and lbound functions. Since you replied so quickly, I'll accept your comment as the solution.
KMcElhineyAuthor Commented:
VB6 Collections are one-based. They have only one property, i.e. Count. The UBound and LBound functions do not work on collections, only on arrays.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now