We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

vb6 code to .net  listbox methods

Fordraiders
Fordraiders asked
on
Medium Priority
299 Views
Last Modified: 2012-06-27
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

Comment
Watch Question

Imran Javed ZiaConsultant Software Engineer - .NET Architect
CERTIFIED EXPERT

Commented:
Hi,
You can use it as

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

Thanks

Author

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


Thanks
fordraiders
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Tyhanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.