Solved

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

Posted on 2009-07-01
3
1,133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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 …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

695 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