|
-
May 12th, 2007, 01:21 AM
#1
Thread Starter
Frenzied Member
[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:
Set lvwitem = Listview1.FindItem(objNode.selectSingleNode("ip").Text)
If lvwitem Is Nothing Then
MsgBox "Couldn't be found"
Set lvwitem = Listview1.ListItems.Add(, , objNode.selectSingleNode("ip").Text)
End If
Last edited by tony007; May 12th, 2007 at 01:26 AM.
-
May 12th, 2007, 04:49 AM
#2
Re: problem finding listview first column value
To get the value of the first column do
vb Code:
Msgbox ListView1.SelectedItems.Text
-
May 12th, 2007, 05:01 AM
#3
Thread Starter
Frenzied Member
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:
I get the following error:
Run-tme error 91:
object variable or with block variable not set
pointing at :
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.
-
May 12th, 2007, 11:02 AM
#4
Re: problem finding listview first column value
Does objNode.selectSingleNode("ip").Text actually return the value you expect?
-
May 12th, 2007, 01:06 PM
#5
Thread Starter
Frenzied Member
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!!!
-
May 12th, 2007, 01:19 PM
#6
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)
-
May 12th, 2007, 01:28 PM
#7
Thread Starter
Frenzied Member
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.
-
May 12th, 2007, 04:50 PM
#8
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.
-
May 12th, 2007, 05:03 PM
#9
Thread Starter
Frenzied Member
Re: problem finding listview first column value
 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!!
-
May 12th, 2007, 05:08 PM
#10
Re: problem finding listview first column value
 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.
-
May 12th, 2007, 05:29 PM
#11
Thread Starter
Frenzied Member
Re: problem finding listview first column value
:-(( not workin again:
Set lvwItem = ListView1.FindItem(Left$(objNode.selectSingleNode("ip").Text, 2), , , lvwPartial)
-
May 12th, 2007, 05:33 PM
#12
Re: problem finding listview first column value
Can you attach a zip file containing your project or a sample project that reproduces the problem?
-
May 12th, 2007, 06:05 PM
#13
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|