Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Collections in a Class


Message #1 by "Jawahar Rajan" <jrajan@h...> on Tue, 28 Aug 2001 17:35:03 -0400
A colection is an object and must be declared and instantiated before use.
In your class Initalize routine, set your new collection and everything will
work just fine.



-----Original Message-----
From: Jawahar Rajan [mailto:jrajan@h...]
Sent: Tuesday, August 28, 2001 5:35 PM
To: professional vb
Subject: [pro_vb] Collections in a Class


All,
When the follwing line of code is executed :
dim wrd as new w
where w is class with several properties and two collections

when trying to add items to the collections an error is raised
"Object variable or With block not set"

Do collections have to be instantiated separately?
When a class is instantiated will the collection in the class be
instantiated as well or will this need to be done seprately?

The class w was made using the Class builder and when adding properties one
of the type used was a collection.Then the following was attempted

dim wrd as new w
with
        .rcds.Add Item:="Books",Key:="1"
        .lines.Add Item:="Magzines",Key:="2"
end with

The error is raised
"Object variable or With block not set"
rcds and lines are both decalred as collections in class w
This is why i ask if Collection need to be instantiated separately from the
class itself

Thanks
Jawahar

  Return to Index