Solved

Empty placeholder to adjust for 1-based array.

Posted on 2006-07-13
2
1,344 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

930 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

9 Experts available now in Live!

Get 1:1 Help Now