Searching for text in a string

I want to search for a certian word in a listbox, if I type in that word I want the word or word's to show up in a seperate textbox. So my question to any of you is... how do you do it! I was thinking along the lines of the INSTR command but have no idea on how to get it started. ANd yes I have looked in all the help files in Visual Basic.




  • VB3 code. You didn't specify the version you are using, but this should be similar to any version.

    For I = 0 to List1.ListCount - 1

    If Instr(List1.List(I), YourWord) > 0 Then

    Text1.Text = (or List2.AddItem) List1.List(I)

    Exit For 'Remove line if you want it to find every entry that matches

    End If

    Next I

  • I have VB5, and I don't understand the 3rd line that you have written, could you help with that please.



  • Sent to your Email.

    I wrote:

    Text1.Text = (or List2.AddItem) List1.List(I)

    I meant:

    Text1.Text = List1.List(I)


    List2.AddItem List1.List(I)

    Sorry, I shortcutted it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!