Solved

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

Posted on 2009-07-01
3
1,109 Views
Last Modified: 2013-11-25
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,
Kevin
0
Comment
Question by:KMcElhiney
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 24756917
use lbound(  array ) and ubound( array )
for collections, they are 1-based.
0
 

Author Comment

by:KMcElhiney
ID: 24757061
Thanks for the reply. I found another reference that says that VB6 collections are indeed one-based:
http://articles.techrepublic.com.com/5100-10878_11-5800272.html
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.
0
 

Author Closing Comment

by:KMcElhiney
ID: 31598887
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.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question