Adding to an arraylist?

R

Rob Meade

Hi all,

I'm using some code I could swear I've used before without problem but I've
run into difficulties and cant see whats wrong....

I have a class which holds other classes - its defined as an ArrayList...

In this class I have an "Add" method...

Public Function Add(ByVal activeDirectoryIISEntry As
ActiveDirectoryIISEntry) As Boolean

' declare variable
Dim Result As Boolean

' check that our object is not nothing
If activeDirectoryIISEntry Is Nothing = False Then

' add webmaster to collection
_collection.Add(activeDirectoryIISEntry)

' populate variable
Result = True

Else

' populate variable
Result = False

End If

' return result
Return Result

End Function

An exception is being produced when this line executes...

_collection.Add(activeDirectoryIISEntry)

which is "Object reference not set to an instance of an object"..

I dont quite understand where its going wrong - when the class is passed
in - its by no means empty, it contains my "entry" class...

Any information/help would be really appreciated.

Regards

Rob
 
R

Rob Meade

[snip]

Whoops - didn't new-in the arraylist in my constructor...

Thanks anyway!

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top