?
Solved

vb6 code to .net  listbox methods

Posted on 2011-04-19
4
Medium Priority
?
287 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

0
Comment
Question by:Fordraiders
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 35424279
Hi,
You can use it as

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

Thanks
0
 
LVL 3

Author Comment

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


Thanks
fordraiders
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 35424431
Try

 lviNoMatch.SubItems(1).Value = lvwDest.Items(iDestM).IndeX
0
 
LVL 3

Author Closing Comment

by:Fordraiders
ID: 35424552
Tyhanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question