dcsimg
Results 1 to 3 of 3

Thread: Arraylist Values not clearing...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2013
    Posts
    216

    Arraylist Values not clearing...

    Hello:

    I have an arraylist that reports errors. In the event that the same command is hit twice, I need to clear the listbox and the arraylist.

    What is happening is that the second time around, it adds doubles, triples, etc. the information.

    Partial code below:

    Code:
            Dim pri As Integer = 0
            Dim err1 As Integer = 0
            Dim err2 As Integer = 0
            Dim err3 As Integer = 0
            Dim err4 As Integer = 0
    
            ' Clear lstErrorDrawings and respective arraylist - not working...
            lstErrorDrawings.Items.Clear()
            ERRORLIST.Clear()
    .
    .
    .
    Code:
           ERRORLIST.Add(pri)
            ERRORLIST.Add(err1)
            ERRORLIST.Add(err2)
            ERRORLIST.Add(err3)
            ERRORLIST.Add(err4)
    
            MessageBox.Show(ERRORLIST(0).ToString & " drawings sent to printers:" & vbCrLf &
                            ERRORLIST(1).ToString & " of Err1: Paper Size not specified," & vbCrLf &
                            ERRORLIST(2).ToString & " of Err2: PDF File does not exist," & vbCrLf &
                            ERRORLIST(3).ToString & " of Err3: Drawing is not in a Released State," & vbCrLf &
                            ERRORLIST(4).ToString & " of Err4: BOM Error, file not found in PDM." & vbCrLf &
                            "....."
                           )
    I have also tried the RemoveAt for each element in the arraylist, as well as both options. Same results.

    Thanks for the help!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    33,132

    Re: Arraylist Values not clearing...

    You really shouldn't be using an ArrayList. That doesn't seem likely to be the issue, but that's an archaic collection. The ArrayList was all you had for VS2002 and VS2003, but then was totally replaced by the List(of T). There's no good reason to still use the older ArrayList.

    However, Clear is how you would clear either one of those, in most cases, so that isn't likely to be the issue. In fact, I'm a bit suspicious about the whole thing. Did you explicitly put a breakpoint on the line ERRORLIST.Clear(), see that ERRORLIST has items, then step forwards one line and check ERRORLIST again? If you haven't done that, then do it. I expect that you will find that ERRORLIST is, in fact, cleared...but then it reloads.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2013
    Posts
    216

    Re: Arraylist Values not clearing...

    Agreed, thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width