Results 1 to 9 of 9

Thread: Listbox and array

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    I want to put the contents of a
    always changing array into a
    listbox... How do you do that?

  2. #2
    Lively Member
    Join Date
    Sep 2000
    Posts
    116
    I don't know if I understood what you're after, but


    Dim MyArray(intArrayCount) As String
    For i=0 To intArrayCount - 1
    MyList.List(i) = MyArray(i)
    Next i
    0101011001000010
    01101111011011100110110001101001011011100110010101110010

  3. #3
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    for x = 1 to ubound(myArray)
    list1.additem myArray(x)
    next x

  4. #4
    Guest
    joefoules:
    i think the loop should be
    for x = 0 to ubound(myArray)
    unless you need to discount myArray(0).

  5. #5
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64

    Talking

    I suppose, depends on how you populate the array in the first place.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Look... If thats in a timer though
    your gonna never clear the array..
    This array changes all the time!

  7. #7
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Correct me if I'm wrong, but you have a dynamic array, one that can be a different size each time. Each time the array is assigned something, you want the elements placed in a listbox. Each time the array changes, the listbox clears and repopulates with the new array information? If so:

    Code:
    'This code is NOT verified.
    
    Private Sub List1Populate()
        List1.Clear
        For X = 0 to UBound(MyArray)
            List1.AddItem MyArray(X)
        Next X
    End Sub
    What'll happen:
    Each time your array changes, call List1Populate. This will clear the listbox and populate it with the current contents of the Array. You could also add this to the same sub your array is being assigned data in, it wouldn't take much work there. More or less, this is exactly the same as the others with the added List1.Clear ...

    If this isn't what you're looking for, a more detailed question might be in order
    -Excalibur

  8. #8
    Guest
    Array's can start at 0 or 1, thus use:
    Code:
    Private Sub List1Populate()
        List1.Clear
        For X = LBound(MyArray) To UBound(MyArray)
            List1.AddItem MyArray(X)
        Next X
    End Sub

  9. #9
    Guest
    Is the loop
    LBnd = LBound(MyArray)
    UBnd = UBound(MyArray)
    For X = LBnd To UBnd

    not more efficient than

    For X = LBound(MyArray) To UBound(MyArray)
    ??


Posting Permissions

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



Click Here to Expand Forum to Full Width