|
-
May 13th, 2000, 05:09 AM
#1
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
-
May 13th, 2000, 05:28 AM
#2
transcendental analytic
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.
-
May 13th, 2000, 08:07 AM
#3
runtime error 381
invalid property array index
and what does the % do?
-
May 13th, 2000, 06:20 PM
#4
transcendental analytic
[/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.
-
May 14th, 2000, 01:36 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|