Solved

Empty placeholder to adjust for 1-based array.

Posted on 2006-07-13
2
1,336 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 500 total points
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

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

16 Experts available now in Live!

Get 1:1 Help Now