Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted

you could try an arraylist , they are pretty cool and can be added to / removed from the same as a listbox etc... eg:

       Dim arrlist As New ArrayList()
       Dim strStrings() As String = {"item1", "item2", "item3"}
       arrlist.AddRange(strStrings)

       arrlist.Remove("item2")

       MessageBox.Show(arrlist.Count)

Posted

I actually found a "collection" object, does exactly what I need:

 

Dim sBackPage As New Collection

 

sBackPage.Add("One") 'adds a page

sBackPage.Add("Two") 'another

sBackPage.Add("Three") ' and another

 

sBackPage.Remove(sBackPage.count) ' removes the last page

 

 

It works good, you think I have any problems with memory usage? I'm not too keen on working with objects TOO much, but what I do know is if I don't dispose or release certain things it makes a dirty mess.

www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
  • 2 weeks later...
Posted
if you are working in vb.net then everything is an object, you need not dispose your objects - that's what the GarbageCollector does for you - kills objects in memory when they are no longer needed, unlike vb6.

mod2software

Home of the VB.NET Class Builder Utility - Demo and Full versions available now!

Posted

watch with collection

 

Hey there,

 

I used a StringCollection CLass for teh same purpose - which is similiar or exactly what I think you might be using. Just a heads up with this class.

 

One, yes it gets picked up by the GC - but there are some erratic behaviors if you don't release resources using it when you are trying to read information into it (from a file per se).

 

Two: The collection object is great when the array is about 150 or so elements in length - after that, performance gets less efficient. Also, you can't perform array methods (like sort) on a collection - you need an array or an arraylist.

 

For that, try wrapping the collection into an arraylist using the ArrayList.Adapter method. For example.

 

dim alist as ArraList = ArrayList.Adapter(your_collection_var)

 

alist.Sort

\\ or any other method to call on it

 

alist.nothing \\ when finished with the wrapper.

 

okay - just a jeads up. Hope it was helpful!

 

inzo

he who forgets will be destined to remember... (E.Vedder)
Posted

I'm not working with that many members, so I hope i'm in the clear. Thanks for the stringcollection advice, i'll switch over to string collection instead of the collection which is probably a collection of objects.

 

As far as wrapping collections into an arraylist, well - that stuffs above my head and I don't understand any of it.

www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...