Results 1 to 5 of 5

Thread: value not found in listview

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    value not found in listview

    Why code in Command2, dont find "California" in column 3?????

    Code:
    Private Sub Command2_Click()
        Dim oItem As ListItem
        Set oItem = Me.ListView1.FindItem("California", lvwSubItem, 3)
        If Not oItem Is Nothing Then
            MsgBox "The Record ID returned is: " & oItem.Text
            Set oItem = Nothing
        Else
            MsgBox "No Items Found"
        End If
    End Sub
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: value not found in listview

    Because that value is not in sub item 3

    The first column is the Text of the list view item the second column is SubItem(1) and the next is subitem(2)

    So you are looking in subItem(3) which contains only numbers where the value you are tryign to find is in SubItem(2)

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,586

    Re: value not found in listview

    Quote Originally Posted by DataMiser View Post
    Because that value is not in sub item 3

    The first column is the Text of the list view item the second column is SubItem(1) and the next is subitem(2)

    So you are looking in subItem(3) which contains only numbers where the value you are tryign to find is in SubItem(2)
    but i need search directly only in column 3 the value"California"... and not in all item of listview.
    can you change my command button code, for that?
    Tks.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: value not found in listview

    FindItem can search the subitems, but not a specific subitem. Also, if searching anything other than the .Text property, partial matches of the search criteria is not allowed, only exact matches. The problem you have is that you are telling it to start at the 3rd listitem, California is in the 1st listitem. The Index is not the subitem index, it is the index to begin searching from.

    Since the lvwSubItem option doesn't allow you to specify which subitem to search in, you'll need to test if what was found was in .SubItem(2). The match could theoretically be in another subitem
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: value not found in listview

    Hey,
    Check this post, it may just be what you're looking for.

    http://www.vbforums.com/showthread.p...=1#post4797799

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