|
-
Mar 21st, 2001, 12:00 AM
#1
Thread Starter
Lively Member
if i have a number of items in a list box lets say a 100 and i want to remove 50 from the middle so 25 to 75. So how can i delete those items fromt he listbox. Al of this would be in a command button
-
Mar 21st, 2001, 12:04 AM
#2
Code:
For x=75 to 25 Step -1
List1.RemoveItem x
Next
try that...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 21st, 2001, 12:09 AM
#3
Thread Starter
Lively Member
no nothing seems to happen when i do this...what could be wrong
-
Mar 21st, 2001, 12:11 AM
#4
did you put it in the Command button's Click Event?
try this
Code:
Private Sub Command1_Click()
x = 1
Do Until x=50
List1.RemoveItem 25
x = x + 1
Loop
End Sub
Don't have VB in front of me, so I can't test it...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 21st, 2001, 12:19 AM
#5
PowerPoster
How bout this:
Code:
Option Explicit
Private Sub Command1_Click()
Dim x As Integer
For x = 75 To 25 Step -1
List1.RemoveItem x
Next
End Sub
Private Sub Form_Load()
Dim x As Integer
For x = 1 To 100
List1.AddItem x
Next
End Sub
-
Mar 21st, 2001, 12:21 AM
#6
Hey look at that...
Just like my first code...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 21st, 2001, 12:23 AM
#7
PowerPoster
hehehe...I know, just had to post exactly what to add to a form since you put in your floating, orphaned code. J/k......
-
Mar 21st, 2001, 12:24 AM
#8
good point...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 21st, 2001, 12:30 AM
#9
Thread Starter
Lively Member
thanks for the help guys!!!!!!!!
-
Mar 21st, 2001, 12:30 AM
#10
PowerPoster
No problem... , couldn't have done it without crypt
-
Mar 21st, 2001, 05:36 PM
#11
Addicted Member
Just a simple little question, you can remove list items by listindex, but not by its text - unless you search for the text using a simple for...next loop.
Any other way?
Matthew
Visual Basic 6.0 Professional
Windows ME & Windows 2000 Professional
-
Mar 21st, 2001, 05:49 PM
#12
PowerPoster
You can use the listindex property, but an item has to be selected or you will invoke an error.
Code:
Private Sub Command1_Click()
List1.RemoveItem List1.ListIndex
End Sub
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
|