Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Empty placeholder to adjust for 1-based array.

Posted on 2006-07-13
2
Medium Priority
?
1,434 Views
Last Modified: 2008-02-01
Hi Guys

I have the following problem with visual basic, this is not the actual code, but should illustrate the problem

I creates a new collection and a iterator, like

Dim collection as Collection
Dim it as Inode

then I create a node and inserts it into the collection, eg

collection.Add( new Inode , "key" )

then I would like to iterate through the collection, something like

For Each it in collection
   ....
next it

But I get an exception with the following message: {"Object reference not set to an instance of an object."}

My own explanation is like follows. When you call "Add" on the collection, a node is automatically generated that are a text string and inserted at the first position in the collection, then my node is added. When I iterate through the collection the first time I get the auto inserted string which cannot be casted to the type of my iterator and when I try to do a next, I get the exception, so basically my question is: Can you avoid to get the autoinserted node or can you avoid this node in your iteration.

Thanks, Niels





0
Comment
Question by:nielsboldt
2 Comments
 

Accepted Solution

by:
Coder1st earned 1500 total points
ID: 17102067
Hi nielsboldt!

I tryed you code and the only thing that I see is that you need to change this line

Dim collection as Collection

to this

Dim [You Collection Name] as New Collection

and that should take care of that error.
0
 

Author Comment

by:nielsboldt
ID: 17106102
Hi

I found the cause of the error, and it was a really stupid mistake in the implementation of the enumerable interface.

Thanks for your time.
Niels
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

824 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