Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Empty placeholder to adjust for 1-based array.

Posted on 2006-07-13
2
Medium Priority
?
1,418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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