Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21273

Is there a way to search a list for an item, then remove it?

$
0
0
Hi there everyone. I am working on a math game where students can make their own custom game patterns. I am working on a way for students to be able to delete custom patterns down the road.

So far I have this..
VB Code:
  1. Dim iczg As Integer
  2.    Dim srch_stringzg As String
  3.    srch_stringzg = LoadGameNameTXT.text    'or whatever you want to search for
  4.    For iczg = 0 To CustomGameList.ListCount - 1
  5.       If CustomGameList.List(iczg) = srch_stringzg Then
  6.          CustomGameList.RemoveItem srch_stringzg
  7.  
  8.       End If
  9.    Next iczg

Basically the name of the pattern is in the LoadGameNameTXT.text. I am trying to get the code to search for it in the CustomGameList listbox, and if found remove it from the listbox, but I am getting a type mismatch error on this line..

CustomGameList.RemoveItem srch_stringzg

Can anyone tell me what I did wrong? :)

Thanks!!

Viewing all articles
Browse latest Browse all 21273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>