Results 1 to 6 of 6

Thread: arrays

  1. #1
    Guest
    i am writing a program that saves information
    to a text file with a UDT that i put into an
    array.

    i load these items in a listbox with the array.

    however, when one is deleted, a blank line is shown
    in the listbox.

    how can i completely remove this dead space
    from my array?

    thankx in advance,
    larryn

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Two options:

    1. Create a new array, and copy the contents into it, missing out the dead one.
    2. Use a Collection - they support add/remove and all the rest.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Or you could also check for blank items while loading the array into the listbox´.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Guest
    along the lines of this?

    Code:
    For LBound(array) to UBbound(array)
       If array(iX) = "" Then
            'what here?
       End If
    Next

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Then you would have to put another counter for reading and shuffling the array to i1.
    Code:
    For i1= LBound(array) to UBbound(array)
        If array(i1) then exit for
    Next i1
    i2=i1
    For i1 = i1 to UBbound(array)
       If array(i1) = "" Then i2=i2+1
       array(i1)=array(i2)
       i2=i2+1
       if i2>ubound(array) then exit for
    Next
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Guest
    thank you kedaman!

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