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

[RESOLVED] Is there a way to remove specific items from a listbox?

$
0
0
Hi there everyone! I am working on removing items from a listbox that end in a specific number.

I use this code from an earlier project to search for items with the letter B and remove them from list1

VB Code:
  1. Dim i As Long
  2.    
  3.     For i = List1.ListCount - 1 To 0 Step -1
  4.       If Mid$(List1.List(i), 1, 1) = "B" Then
  5.       List1.RemoveItem i
  6.       End If
  7.       Next


I would like to do the same thing, but the issue now, is instead of removing items with a B, I would like to remove whatever is the last digit in a textbox called Searchtxt.text

For example, if I entered the number 23 in the textbox, I would like to search for any number in the list1 that has a 3 at the end of it. I don't think Mid$ would work for this though, because sometimes the number entered would be 1 digit, in which case it would just search for that anyway, or a 3 digit number, but regardless of how many digits are entered, it only looks for matches for numbers with the same last digit and removes them.

Would Mid$ work for that?

Thanks!

Viewing all articles
Browse latest Browse all 21237

Trending Articles



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