Pro VB.NET 2002/2003For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
basicly i need to creat lots of instances of a class called newspaper, in real time. the user can input data in to some text boxes on a form, click on a button at the bottem and it creates a instance of the class. would this be posible at all? or would i have to create a a set number of instances befor, and acess them through an array or something? any ideas?
One way is to create an array whose type is this object. When you want a new instance of the class, ReDim the array to be 1 element larger, and set that new element as a New instance of the class. (In VB6 this requires redimming with the Preserve keyword, that might be the case still with .NET...)
Another way is to use a Collection. When you add the item to the Collection, you can set the key to a meaningful string, and use that string to gain access to the class later.