Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I m working on this code and i have noticed that i will get the list and it starts from 0 then creates a line for every application thats installed on the computer. The issue i m having is when i query the list item #1 shows at the beggining and the last item in the list. Please help i have tried changing the code but i dont know where i m goofing up at i cant have any item repeating itself.

in the list it will show
Example.

0.adobe reader
1.office 2010
2. IE8
3.Office 2010

now i normally have 50 items in the list and #1 will be that and number #51.

VB
objsh = CreateObject("WScript.Shell")

    strObject = "C:\Temp\ASERVICE.EDM"

    Dim process = GetObject("winmgmts://./root/novadigm:NVD_Agent")
    Dim method = process.Methods_("GetValue")
    Dim inParameters = method.inParameters.SpawnInstance_()
    inParameters.Path = strObject
    Dim outParameters = process.ExecMethod_("NumberOfInstances", inParameters)
    Dim StrHeaps = (outParameters.InstanceCount)
    num_TextBox.Text = StrHeaps
    For i = 0 To StrHeaps Step +1
        inParameters.Index = i

        inParameters.Property = "ZOBJNAME"
        outParameters = process.ExecMethod_("GetValue", inParameters)
        Dim Value1 As String = outParameters.Value

        inParameters.Property = "ZAVIS"
        outParameters = process.ExecMethod_("GetValue", inParameters)
        Dim Value2 As String = outParameters.Value

        inParameters.Property = "NAME"
        outParameters = process.ExecMethod_("GetValue", inParameters)
        Dim Value3 As String = outParameters.Value

        inParameters.Property = "INSTDATE"
        outParameters = process.ExecMethod_("GetValue", inParameters)
        Dim value5 As String = outParameters.Value

        'Date
        Dim str As String
        Dim strArr() As String
        Dim count As Integer
        Dim value6 As String
        str = value5
        strArr = str.Split("T")
        For count = 0 To strArr.Length - 2
            value6 = (strArr(count))
        Next

        Dim value4 = ListView1.Items.Count
        Dim item As New ListViewItem(value4)
        item.SubItems.Add(Value1)
        item.SubItems.Add(Value2)
        item.SubItems.Add(Value3)
        item.SubItems.Add(value6)
        ListView1.Items.Add(item)
        ListView1.FullRowSelect = True
    Next

End Sub
Posted

If you set a breakpoint, you can step through your code and see for yourself where the value is getting messed up.

Consider giving your variables meaningful names instead of ListBox1, Value1 and Value2.
 
Share this answer
 
Comments
Zachary.shupp 13-Feb-12 19:30pm    
ok i set the break point and i didnt see anything stand out. I do know i need to chenge my naming but i m just trying to get this to work. I m not a big programmer the guy from work just quit and now i m having to fill in till we get a new person in so help would be great.
i figured out how to remove the duplicate via code:

Cae1.ListView1.Items(Cae1.ListView1.Items.Count - 1).Remove()

hope this helps someone else.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900