Getting the value of the second column of a listview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #1

    Getting the value of the second column of a listview

    Hello World

    I have this code:

    [CODE=vb .net]Windows.Forms.C ursor.Current = Cursors.WaitCur sor

    Call Main.SetConnect ion()
    For i = 1 To frmSchedules.lv wSchedules.Item s.Count

    Command = New OleDbCommand("S elect * From Subjects Where SubjectCode " & _
    "Not In ('" & frmSchedules.lv wSchedules.Item s(i).SubItems(1 ).Text & _
    "')", dbConnection)
    Command.Command Type = CommandType.Tex t
    Data = Command.Execute Reader
    lvwSubjects.Ite ms.Clear()
    While Data.Read
    Item = lvwSubjects.Ite ms.Add(Data(0))
    Item.SubItems.A dd(Data(1))
    End While
    Next i

    Data.Close()
    Main.CloseConne ction() 'Close Connection
    Windows.Forms.C ursor.Current = Cursors.Default[/CODE]

    Everytime I execute this it fails me. and it says InvalidArgument =Value of '9' is not valid for 'index'. My main purpose is to display only the subjects in a listview1 that are not present in a listview2. Waiting for your replies : )

    Rey Sean
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I believe you want:
    [code=vbnet]
    For i = 1 To (frmSchedules.l vwSchedules.Ite ms.Count -1)
    [/code]

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      Originally posted by Plater
      I believe you want:
      [code=vbnet]
      For i = 1 To (frmSchedules.l vwSchedules.Ite ms.Count -1)
      [/code]
      Ah I see. I had a wrong calculations LOL. Thanks Plater.

      Rey Sean

      Comment

      Working...