Solved

Empty placeholder to adjust for 1-based array.

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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