Results 1 to 5 of 5

Thread: listboxes, removing....

  1. #1
    Guest
    I need to remove more than one item from a list box...

    here is the code

    Code:
    Private Sub Command1_Click()
    ff = FreeFile
    Open "c:\windows\desktop\list\list.txt" For Input As #ff
    Do Until EOF(ff)
    Input #ff, this
    List1.AddItem (this)
    Loop
    Close #ff
    End Sub
    
    Private Sub Command2_Click()
    'On Error GoTo that
    'List1.RemoveItem List1.ListIndex
    'Exit Sub
    If List1.SelCount > 1 Then
    Do Until List1.SelCount = 0
    List1.RemoveItem List1.ListIndex
    
    Loop
    ElseIf List1.SelCount = 1 Then
    List1.RemoveItem List1.ListIndex
    ElseIf List1.SelCount = 0 Then
    Exit Sub
    End If
    'that: MsgBox (Err.Description)
    
    
    End Sub
    ignore the comments, those were pieces of code I thoought about using..
    this code works fine and dandy for removeing single items, and removing items that are right next to eachother, but if there is an item in between two selected items, it gets deleted also, please help me.
    thank you
    Dennis Wrenn

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thats an indirect way of doing it, try this instead:
    Code:
    Dim n%
    For n = 0 To List1.ListCount - 1
     If List1.Selected(n) Then List1.RemoveItem n: n = n - 1
    Next n
    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.

  3. #3
    Guest
    runtime error 381
    invalid property array index



    and what does the % do?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    [/code]
    Dim n%
    For n = 0 To List1.ListCount - 1
    If n >= List1.ListCount Then Exit Sub
    If List1.Selected(n) Then List1.RemoveItem n: n = n - 1:
    Next n
    [code]
    the % is instead of "as integer"
    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.

  5. #5
    Guest
    it works,
    thank you SOOOOO much...
    [/code]
    thanks again

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