Identifying total number of items in an array?

Discussion in 'AutoCAD' started by pkirill, Apr 22, 2004.

  1. pkirill

    pkirill Guest

    What is good way to display the total number of items in a dynamic array?
    For example, I have two list boxes. One list box displays a folder's worth
    of file names. The second box displays file names selected from the first
    box. In the background, I am trying to keep a array of items matching the
    contents of second box - only this array is Folder Path + File Name. I
    *think* it's working, but I can't figure out a reliable way to check the
    status of the array. The main reason I worry is because there are options
    to add and subtract from the second list and I need to be sure items
    subtracted from the second list are also subtracted from the background
    array...

    Code is below - thanks for any help!!!

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Public Sub MakeFullPathList()
    Dim j As Integer

    ReDim FileList1(0 To List1.ListCount)
    For j = 0 To List1.ListCount - 1
    FileList1(j) = strListPath & List1.List(j) & ".dwg"
    msgItem = FileList1(j) & vbCr & msgItem ; this works for adding to the
    array, but is not a true representation of the array
    Next
    MsgBox msgItem
    End Sub
     
    pkirill, Apr 22, 2004
    #1
  2. pkirill

    HJohn Guest

    This is how I would handle it. Assuming you really need the two lists then, you have to search the first list for items selected for removal on the second list. You could search for the file path or the name, however I think I would add a third column to the lists containing a numeric index, created as you add files to the first list. When you select an item on the second list, it would be much easier to find a match on the first list and remove it as well.
     
    HJohn, Apr 22, 2004
    #2
  3. pkirill

    HJohn Guest

    I forgot to mention that I wouldn't use the array.
     
    HJohn, Apr 22, 2004
    #3
  4. Ubound(FileList1) and Lbound(FileList1) gives the dimensions of the array,
    including any unused cells. I don't have time to look at your questions or
    HJohn's answers any closer, so take my answer FWIW.

    James
     
    James Belshan, Apr 22, 2004
    #4
  5. pkirill

    pkirill Guest

    I think both answers were what I was looking for! Ubound and Lbound were
    the things I needed to answer the question and "don't use an array" seems to
    be more to the point. Using an array for list handling is, in fact, not the
    best way to go about it...


    Thanks guys!
     
    pkirill, Apr 23, 2004
    #5
  6. pkirill

    A Seidel Guest

    I use arrays and collections for managing lists all the time. I
    prefer to avoid managing the list "within the list". For example it
    seems to be much easier to manage the array or collection using the
    selected list item, then clear the list and reassign the list to the
    updated array or collection.
     
    A Seidel, Apr 23, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.