Im designing a software for fun.
but I stuck in somewhere in listboxes. what I'm trying to do is like this:
you write something in in textbox1.
after press a button it seach if a word like that is on listbox 1. if that is true than it send a item from listbox2.

something like those bots on different chats. who text something..

PS: is not for bot things or chatting. just some reseach

I'm not clear on what you are asking. Could you possibly post an example with sample data? Please post, as well, any code you've tried so far.

I had no idea so was testing like this

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1.Text = ListBox1.Items(1) Then

            TextBox2.Text = ListBox2.Items(1)

        End If
    End Sub

this is a view of the form

LB= listbox
TB= textbox

Capture.JPG

after press send. the software need to check if the item is on the LB1 and if it is it sends a text from lb 2 (lb2 text is optional) if it is not. it says
"sorry did not found that word"

you write something in in textbox1.

In your example you don't have anything in textbox1.

after press a button it seach if a word like that is on listbox 1. if that is true than it send a item from listbox2.

What item is it supposed to send from listbox2 and where is it supposed to send it? You have some items in both listboxes and nothing anywhere else. I still have no idea what you want to do.

Textbox1 is that before the button. if type there Hi in textbox 2 nothing will show. (TB2 is multiline)

but found a harder way. is it possoble after I press the button it search if that text exist on listbox 1. ?

Textbox1 is that before the button

I know that. You have it labelled in the picture. At the top you said

you write something in in textbox1

Now you are saying

if type there Hi in textbox 2 nothing will show

I think our first problem is the language barrier. Your English is much better than my Albanian (non-existent) so unless you can get help with explaining your problem I don't think I'll be able to offer any advice.

forgive me about that.

look what I want to say: if you type Hi in textbox 1 and press the button, the software checks if the text like in textbox1 is a item in listbox1.
is that possible?

That's easy enough to do

Private Sub btnSend_Click(sender As System.Object, e As System.EventArgs) Handles btnSend.Click

    ListBox2.Items.Clear()

    For Each item As String In ListBox1.Items
        If item.Contains(TextBox1.Text) Then
            ListBox2.Items.Add(item)
        End If
    Next

End Sub

That will copy all items containing the string in TextBox1 from ListBox1 to ListBox2. If you want an exact match then use

If item = TextBox1.Text Then

If you want a dynamic version (ListBox2 updates while you type) then see this thread

thank you very much for your help :)

No problem. Glad we were finally able to get on the same page. Feel free to post follow-up questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.