Results 1 to 13 of 13

Thread: [RESOLVED] problem finding listview first column value

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Resolved [RESOLVED] problem finding listview first column value

    Hi all I am trying to use the following code to find a value in listview first column cell but it keeps failing to find.The value exist but it says it didn't find the value. The value in listview first column is an IP value. I be happy if some one tell me how to make this work .Thanks

    1 Code:
    1. Set lvwitem = Listview1.FindItem(objNode.selectSingleNode("ip").Text)
    2.         If lvwitem Is Nothing Then
    3.            MsgBox "Couldn't be found"
    4.           Set lvwitem = Listview1.ListItems.Add(, , objNode.selectSingleNode("ip").Text)
    5.                   End If
    Last edited by tony007; May 12th, 2007 at 01:26 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: problem finding listview first column value

    To get the value of the first column do
    vb Code:
    1. Msgbox ListView1.SelectedItems.Text

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: problem finding listview first column value

    Hack i want to use Listview1.FindItem to check if a perticuler xml item already exist on first column of listivew or not. But it keeps telling me couldn't find it while i see it on listview!!! I want to check if it exist then i don't need to update it.But now it can't find the item and keeps updating it for no reason!!

    I used MsgBox objNode.selectSingleNode("ip").Text and i saw it has the correct value but Listview1.FindItem always gets null value!!!


    I tried using:
    MsgBox lvwItem
    I get the following error:
    Run-tme error 91:

    object variable or with block variable not set
    pointing at :

    MsgBox lvwItem
    also i tried using:

    MsgBox lvwItem = ListView1.FindItem(objNode.selectSingleNode("ip").Text)
    i get this error:

    Run-tme error 91:

    object variable or with block variable not set
    pointng at :
    MsgBox lvwItem = ListView1.FindItem(objNode.selectSingleNode("ip").Text)
    could any one tell me how to fix these erros so i debug the program corectly?Thanks in advance:-))
    Last edited by tony007; May 12th, 2007 at 05:18 AM.

  4. #4

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: problem finding listview first column value

    martin thanks for your reply. Yes it returns the correct value. I check it via :

    MsgBox objNode.selectSingleNode("ip").Text

    objNode.selectSingleNode("ip").Text is an IP number not text.I still don't know why Listview1.FindItem returns nothing!!!

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: problem finding listview first column value

    Try

    Set lvwitem = Listview1.FindItem(objNode.selectSingleNode("ip").Text, , lvwPartial)

    and if that doesn't work try

    Dim strIP As String
    strIP = objNode.selectSingleNode("ip").Text
    Set lvwitem = Listview1.FindItem(strIP, , lvwPartial)

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: problem finding listview first column value

    I tried both of them it both failed to find the ip!!!

    first one:

    Set lvwItem = ListView1.FindItem(objNode.selectSingleNode("ip").Text, lvwPartial)
    for second one it failed to find it again!!

    Dim strIP As String
    strIP = objNode.selectSingleNode("ip").Text
    'MsgBox strIP
    Set lvwItem = ListView1.FindItem(strIP, lvwPartial)
    i have feeling that Listview1.FindItem(...) is not looking at the first coloum of listview!! Because the value passsed to it is corret value to look for but it fails to find it!!
    Last edited by tony007; May 12th, 2007 at 02:07 PM.

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: problem finding listview first column value

    Please note that my example was wrong (yours was too). There should be THREE commas and not two as in my examples or one as in yours.

    Set lvwItem = ListView1.FindItem(objNode.selectSingleNode("ip").Text, , , lvwPartial)

    And FindItem definately looks for the ListItem object's Text property.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: problem finding listview first column value

    Quote Originally Posted by MartinLiss
    Please note that my example was wrong (yours was too). There should be THREE commas and not two as in my examples or one as in yours.

    Set lvwItem = ListView1.FindItem(objNode.selectSingleNode("ip").Text, , , lvwPartial)

    And FindItem definately looks for the ListItem object's Text property.
    Martin i tried again .It keeps failing again. It seems finditem can't find ip value!!Because ip has dots and it is integer. May be that is the problem!!

  10. #10
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: problem finding listview first column value

    Quote Originally Posted by tony007
    Martin i tried again .It keeps failing again. It seems finditem can't find ip value!!Because ip has dots and it is integer. May be that is the problem!!
    Try it (again with 3 commas) but use

    Left$(objNode.selectSingleNode("ip").Text, 2)

    and see if that finds anything.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: problem finding listview first column value

    :-(( not workin again:

    Set lvwItem = ListView1.FindItem(Left$(objNode.selectSingleNode("ip").Text, 2), , , lvwPartial)

  12. #12

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: problem finding listview first column value

    i think i need some rest. lol. I fixed it. Problem was that i was clearing the listview before reaching finditem that is why it was failing to findd it!! Mart many thank for helping me :-))
    Last edited by tony007; May 12th, 2007 at 06:36 PM.

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