Click here to Skip to main content
15,907,875 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How show a message when mismatch combo box text and combo listed item are not match? The message is "Item Not Found" I create a project in vb.net 2008 with ms access data base.
Item list are in combo box but if I not click on the list item just anything it is stay on the combo box, now in this position when I go to other field then show the message box "Item not found".
Fox Example :
combo box item is
A
B
C
D
E
F

But if I type g/h/i/j/..... it stay on the combo box no objection
please help me.

What I have tried:

If ComboBox1.SelectedItem.text = ComboBox1.Text Then
            MsgBox("ok")
        Else
            MsgBox("not")
        End If
Posted
Updated 26-Feb-17 11:18am
v2

I remember answering this exact same question earlier today and the answer still remains the same.

If you set a breakpoint on the line:
VB
If ComboBox1.SelectedItem.text = ComboBox1.Text Then
and look at the values of the variables being compared, you will have your answer.
 
Share this answer
 
v2
Comments
Jayanta Modak 26-Feb-17 13:18pm    
Sir, please give me the solution I am beginner in VB.Net. please give me the code
Combobox style is simple combo box
Graeme_Grant 26-Feb-17 13:52pm    
Sorry, but we are not here to write your code for you. Here is a video introducing you to the VS debugger: Basic Debugging with Visual Studio 2010 - YouTube[^]
Ralf Meier 26-Feb-17 14:27pm    
Perhaps you take a look at the Properties of the ComboBox ...
and another tip :
What do you want to do ? Comparing if one Item ... or perhaps comparing with a List of Items ?
Programming is a little bit more than placing Controls on a Form ...
I think the approach is wrong, you should look into the FindStringExact method. Think of it like you want to find out what you enter exists in the combo box and not what you entered (comboBox1.Text) is the same as you selected (ComboBox1.SelectedItem.text).

VB
if (comboBox1.FindStringExact(comboBox1.Text) > -1) then
 
Share this answer
 
Comments
Jayanta Modak 26-Feb-17 23:43pm    
Thanks sir, It is work. many many thanks.
I have a question
when I click on combo box list are showing.
example:
Ram
Arijit
Soumya
soubarna
tarak
i want to just type "rna" select or only show the word "soubarna" how it is possible?
Please help me........
Advance say Thanks..............
Bryian Tan 27-Feb-17 0:06am    
Sound like you need to make the code to filter the source first before binding it into the combobox. I'm not sure how you code is currently populating the combobox. Let said it use this query "Select Name from Table"

Then your new query will look like "Select Name from Table WHERE Name LIKE '%" + comboBox1.Text + "%'" . This is just an example. Make sure to use best practices to prevent SQL injection.
Jayanta Modak 27-Feb-17 1:00am    
I create ms access database because I don't know sql. So, please tell me where I Add this code. combo box attached with access database.
database name---krm
table name ------------- rec sub
field name-------- prd id
Bryian Tan 27-Feb-17 1:13am    
Can you start a new thread so other member can assist you? I'm going to bed :) 1am here.
Jayanta Modak 28-Feb-17 11:32am    
https://www.codeproject.com/Questions/1173238/How-to-create-quick-find-from-combo-list

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900