is this possible?
Yes it is.
First, here's a very straightforward solution for the search. You need a list box, text box and a button. Type a search-term in the text box and press the button.
Private Sub SearchListBox(ByVal searchTerm As String) ' Fill test data ListBox1.Items.Clear() ListBox1.Items.Add("Apple") ListBox1.Items.Add("Banana") ListBox1.Items.Add("Guava") ListBox1.Items.Add("Pineapple") ListBox1.Items.Add("Peach") ' Loop items For Each lbItem As Object In ListBox1.Items ' Case-sensitive match If lbItem.ToString = searchTerm Then ' Match found: set as selected item and exit procedure ListBox1.SelectedItem = lbItem Return End If Next End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click ' SearchListBox(TextBox1.Text) End Sub
You may have to modify this approach for your specific needs, like case-insensitive search or "search as you type" search.
Also, see if this helps.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged With ListBox1 If .Items.Contains(TextBox1.Text) Then .SelectedItem = TextBox1.Text Else .SelectedIndex = -1 End With End Sub
Your codes guys are awesome. I tested them both, however, they do just the same. How about, making a search that is not case-sensitive? That's what I need here,
Not case-sensitive? WTF? You gonna pay extra for that or are you just asking for a freebie? :D
See if this helps.:)
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged With ListBox1 .SelectedIndex = -1 '// -1 Index ='s No.Item.Selected. If Not TextBox1.Text = "" Then For Each itm As String In .Items '// loop thru items. If itm.ToLower = TextBox1.Text.ToLower Then '// Case inSensitive search. .SelectedItem = itm '// select item. Exit For '// exit loop since item located. End If Next Exit Sub '// just.because the next 2 lines are not worth reading. :) End If End With End Sub
As always, this community is really my angel... This thread is solved, thanks
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Here is the sample output that I ...
Hello All ...
Iam Getting An Error With try to excecute the stored procedure .
I have Have Sql database , the stored procedure like so :
USE [MPRS] GO /****** Object: StoredProcedure [dbo].[Search_Licenses_By_Number] Script Date: 26-Nov-16 8:06:52 AM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE ...
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...