How to load an object's property which is an array list?

  • Thread starter Thread starter Derek Martin
  • Start date Start date
D

Derek Martin

I have an object which I set up like this:
Public Class Person
....
Protected m_timelists as ArrayList
....
Property timelists() as ArrayList
Get
timelists = m_timelists
End Get
Set (ByVal Value as ArrayList)
m_timelists = Value
End Set
End Property

Is this legal and valid??? If yes, keep going:
Now I want to set it with some objects:

PersonList.addtimeobject(myUserid, time) 'Time object is previously created
and valid

Public Class PersonList
Dim personlist as new ArrayList 'To hold all the person objects
....
Public Function addtimeobject(ByVal userid as string, ByVal time as object)
Dim i as integer = 0
For i = 0 to personlist.count-1
if personlist(i).userid = userid then
personlist(i).timelists.add(time)
end if
Next
End Function

Error returned: Object variable or With block variable not set. This is
occurring on the timelists Arraylist Property Get and Set areas.

Can someone assist???? Thanks!
 
Derek Martin said:
I have an object which I set up like this:
Public Class Person
...
Protected m_timelists as ArrayList
...
Property timelists() as ArrayList
Get
timelists = m_timelists
End Get
Set (ByVal Value as ArrayList)
m_timelists = Value
End Set
End Property

Is this legal and valid???

Yes, but in the example you never assign anything to the timelists property,
so m_timelists is still Nothing and you get...
Error returned: Object variable or With block variable not set.
This is occurring on the timelists Arraylist Property Get and Set
areas.

.... this error.

Declare
Protected m_timelists as NEW ArrayList
or assign an arraylist to the timelists property.
 
Back
Top