Solved

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

Posted on 2009-07-01
3
1,066 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 142

Accepted Solution

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

Author Comment

by:KMcElhiney
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now