Hi there all! I am finishing up a game that demonstrates probability to students, and what I have is a listbox that is randomized, then the prog picks an item to add to a label caption. Then it removes that one item that was in the label caption. I was wondering if there was a way to remove all instances of whatever was in that label caption from the listbox?
I use this to randomly pick an item and it works GREAT.
Now this will definitely remove the item, but as mentioned before I would like to remove all instances of that item. In an earlier thread, advice for a loop was given, which is great as a loop should go through the listbox and look/remove the label caption, but how do I set it up?
Dim i As String (would it be a string since it is a name I am looking for)
For i = 1 To CInt(TicketDrawWinnerLBL.Caption)
StudentList.RemoveItem TicketDrawWinnerLBL.Caption
Next
I don't know if this is important to mention, but the list has by this point been mixed up, so the items are not all together, for ex: the name BOB would be mixed up with the other student names. :) Thanks for your help!!!
I use this to randomly pick an item and it works GREAT.
VB Code:
Public Sub PickAWinnerNOW() Dim lIndex As Long If StudentList.ListCount Then lIndex = Int(Rnd * StudentList.ListCount) 'This is where the program will add the item to the label caption TicketDrawWinnerLBL.Caption = StudentList.List(lIndex) 'Now have the program remove the item from the listbox StudentList.RemoveItem lIndex End If
Now this will definitely remove the item, but as mentioned before I would like to remove all instances of that item. In an earlier thread, advice for a loop was given, which is great as a loop should go through the listbox and look/remove the label caption, but how do I set it up?
Dim i As String (would it be a string since it is a name I am looking for)
For i = 1 To CInt(TicketDrawWinnerLBL.Caption)
StudentList.RemoveItem TicketDrawWinnerLBL.Caption
Next
I don't know if this is important to mention, but the list has by this point been mixed up, so the items are not all together, for ex: the name BOB would be mixed up with the other student names. :) Thanks for your help!!!