Results 1 to 5 of 5

Thread: listbox search

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    listbox search

    i have a listbox with some items
    a textbox with a word
    a richtextbox with a paragaph


    there is some of the words in the paragraph followed by a listbox item


    check the richbox
    if the word which in the textbox is followed by one of the listbox items then

    delete that item from the richbox
    delete that item from listbox

    endif




    how can do this

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox search



    for example

    listbox items are:
    hello mary
    need sugar
    teach them
    good by


    text1.textis:
    Salma


    richtext.text is:
    example1: hfe urefheur hrfer f Salma need sugar jdsud hdcbuds

    in this case the word Salma is followed by on of the list items
    so delete this item from the list and delete from the richtext

    so we will get this :
    listbox items are:
    hello mary
    teach them
    good by


    richtext.text is:
    example1: hfe urefheur hrfer f Salma jdsud hdcbuds

    example2: hfe urefheur hrfer f Salma jdsud hdcbuds



    here the word Salma is followed by a word which is not an item of the list
    so nothing will happen in this case


    is it clear now

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: listbox search

    try this
    VB Code:
    1. Dim iPos As Integer
    2.     For i = 0 To List1.ListCount - 1
    3.         iPos = InStr(1, List1.List(i), txtText1.Text)
    4.         If Trim(txtText1.Text) = "" Then Exit For
    5.         If iPos > 0 Then
    6.             txtText1.Text = Mid(txtText1.Text, 1, iPos - 1) & Mid(txtText1.Text, iPos + Len(List1.List(i)))
    7.             List1.RemoveItem (i)
    8.         End If
    9.         iPos = 0
    10.     Next
    change the control names to suit your requirement
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: listbox search

    Hi ganeshmoorthy
    i tried the code
    but i didn't work

    i think because it should search the richtextbox for the word first then check
    if it followed by on of the list items then
    delete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width