vb6 code to .net listbox methods

vb.net 2008

code was previously vb6..

I need correct syntax for listview items index


error on these lines below:

lviNoMatch = lvwMissing.Items.Add
                    lviNoMatch.Text = lvwDest.Items(iDestM).Text
                    lviNoMatch.SubItems(1) = lvwDest.Items(iDestM).Index

Thanks
fordraiders
Public Sub AutoMap()

        ' ========================= ee
        ' WORKING
        Dim iSrc As Integer
        Dim iDest As Integer
        Dim lviMatch As ListViewItem

        For iSrc = 1 To lvwSource.Items.Count
            For iDest = 1 To lvwDest.Items.Count
                If lvwSource.Items(iSrc).Text = lvwDest.Items(iDest).Text Then
                    lviMatch = lvwMap.Items.Add
                    lviMatch.Text = lvwSource.Items(iSrc).Text
                    lviMatch.SubItems(1) = lvwSource.Items(iSrc).Index
                    lviMatch.SubItems(2) = lvwDest.Items(iDest).Text
                    lviMatch.SubItems(3) = lvwDest.Items(iDest).Index

                    Exit For
                End If
            Next iDest
        Next iSrc
        ' ========================== ee

        ' ========================== ee
        ' looking for missing data fields in destination    lvwMissing
        Dim iSrcM As Integer
        Dim iDestM As Integer
        Dim lviNoMatch As ListViewItem

        For iSrcM = 1 To lvwSource.Items.Count
            For iDestM = 1 To lvwDest.Items.Count
                If lvwDest.Items(iDestM).Text <> lvwSource.Items(iSrcM).Text Then
                    lviNoMatch = lvwMissing.Items.Add
                    lviNoMatch.Text = lvwDest.Items(iDestM).Text
                    lviNoMatch.SubItems(1) = lvwDest.Items(iDestM).Index
                    Exit For
                End If
            Next iDestM
        Next iSrcM
        ' ============================ ee

    End Sub

Open in new window

LVL 3
FordraidersAsked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Try

 lviNoMatch.SubItems(1).Value = lvwDest.Items(iDestM).IndeX
0
 
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,
You can use it as

lviNoMatch = lvwMissing.Items.Add(lvwDest.Items(iDestM).Text)
        lviNoMatch.SubItems(1) = lvwDest.Items(iDestM).Index

Thanks
0
 
FordraidersAuthor Commented:
 lviNoMatch.SubItems(1) = lvwDest.Items(iDestM).IndeX  <--------  ERROR VALUE TYPE OF INTEGER CANT BE CONVERTED TO System.Windows.Forms.ListViewItem.ListViewSubItem


Thanks
fordraiders
0
 
FordraidersAuthor Commented:
Tyhanks
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.