Discussion in 'Questions (Windows Mobile)' started by tvrman, Jun 29, 2007.

  1. tvrman

    tvrman Member Licensed User


    How can i clear an Arraylist?

    i use
    FileSearch (al1, appPath, "*.csv")
    For i = 0 to al1.Count - 1
    End Sub

    I need serveral times to reload above situations in an listbox, the listbox can be cleared but the Arraylist not?
    Last edited: Jun 29, 2007
  2. tvrman

    tvrman Member Licensed User

    i found it ,


  3. sirnono

    sirnono New Member

    Arraylist disposal

    Hi Erel,

    I take benefit of this new subject about Arraylists to ask if there is a way to dispose Arraylists objects added at runtime ?

    In fact, if i add a button to a form with the AddButton method then dispose and add it again, there is no problem.

    But doing the same with an arraylist raises an error.


    ' working code

    msgbox("button added")
    msgbox("button disposed")
    msgbox("button added again")

    ' not working code

    msgbox("arraylist added")
    msgbox("arraylist disposed but in fact not really :)")
    msgbox("well error on above line")

    Well it is still possible to clear the arraylist and add an error handler when trying to add one but i only wanted to know if this was a normal/wanted behaviour.

    Thanks in advance.

    ps: I attached some code example to illustrate :)
    This example also shows how to use a hidden disposable listbox control to mimic the arraylist behaviour.
    The drawbacks of this is we need a form to add the listbox to and the list cannot be sorted automatically with a 'sort method' :/
    There may be other drawbacks not mentionned or just forgotten here ;)

    Attached Files:

  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I've tried myself and couldn't get it to work.
    At first I thought that it might not work with the Control keyword and so attempted to Dispose it directly.
    However a quick glance at the help-file and it appears that the Dispose Method is not available for an ArrayList - Sorry.

  5. Cableguy

    Cableguy Expert Licensed User

    If you are going to use the same arraylist then try just to clear it...
    You can check that an array list already exist by trapping the error generated upon trying to re-create it...
    like this

    addarraylist(myarray) ' if myarray already exist it jumps to error
    return ' stops the execution of the remaing code of the sub
    do whatever you like, possably create "myarray2"
  6. sirnono

    sirnono New Member

    To CableGuy, yep, we need to use errorlabel not to get the error message.

    To RandomCoder, the dispose method does not appear in the help file but seems to exist anyway :confused:

    If you add one arraylist manually with the form editor then in the code you tap "arraylist1." to see the possible methods you will notice the dispose one.

    Is this only a method provided by a generic interface with no implementation behind or why in any other case does this method seem to be available ?

    Thanks for your replies ;)

  7. RandomCoder

    RandomCoder Well-Known Member Licensed User

    This would appear to be a bug and so I'll add it to the 'Bugs and Errors' section of the Forum.
    It should either be made available as a Method or removed from the list.

  8. Erel

    Erel Administrator Staff Member Licensed User

    The dispose method is not implemented for ArrayLists.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice