listview add control VB6

Dear friends

Maybe can someone support me with this problem in VB6,
I don't know why the error "out of bounds" while adding values to the listview.

Thank you in advance for your support

For k = 1 To datos.nels - 1
    Dim nod1, nod2 As Integer
    ReDim km(1 To Tipo.nodof * datos.nnod, 1 To Tipo.nodof * datos.nnod) As Double
    nod1 = datos.Listbar.ListItems(k).SubItems(1)
    nod2 = datos.Listbar.ListItems(k).SubItems(2)
    For i = Tipo.nodof * (nod1 - 1) + 1 To Tipo.nodof * nod1
        For j = Tipo.nodof * (nod2 - 1) + 1 To Tipo.nodof * nod2
            km(i, i) = Lklocal.ListItems(6 * (k - 1) + i - Tipo.nodof * (nod1 - 1)).SubItems(i - Tipo.nodof * (nod1 - 1)) '+ km(i, i)
            km(j, j) = Lklocal.ListItems(6 * (k - 1) + j - Tipo.nodof * (nod2 - 1)).SubItems(j - Tipo.nodof * (nod2 - 1)) '+ km(j, j)
            km(i, j) = Lklocal.ListItems(6 * (k - 1) + i - Tipo.nodof * (nod1 - 1)).SubItems(j - Tipo.nodof * (nod2 - 1)) '+ km(i, j)
            km(j, i) = Lklocal.ListItems(6 * (k - 1) + j - Tipo.nodof * (nod2 - 1)).SubItems(i - Tipo.nodof * (nod1 - 1)) ' + km(j, i)
            Dim lgmi, lgmj As ListItem
            Set lgmi = LMGM.ListItems.Add(i)
            lgmi.ListSubItems.Add , , km(i, i)
            lgmi.ListSubItems.Add , , km(j, i)
            Set lgmj = LMGM.ListItems.Add(j)
            lgmj.ListSubItems.Add , , km(j, j)
            lgmj.ListSubItems.Add , , km(i, j)
        Next j
    Next i
Next k

Open in new window

Frank PatricioAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
The following is typical code for adding to a Listview. Notice that there no index value at the end of the ListItems.Add line.
Set itmX = lvFind.ListItems.Add(, , CStr(mrsProducts!ProductName))
                itmX.SubItems(1) = CStr(mrsProducts!SupplierID)
                itmX.SubItems(2) = mrsProducts!CategoryID

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.