Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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