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

Sin-t-tulo.png
Frank PatricioAsked:
Who is Participating?
 
Martin LissConnect With a Mentor Older 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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.