Good Day All,

I am having issues making reference to .subitems(5) of ListViewStudents below, I can get to .subitems(4) with no issue but it tells me .subitems(5) does not exist. lsvFemaleStudents has 6 columns therefore it should have 5 subitems right?
Does anyone know if there is a restriction when I use ListviewStudents to move thru the list?

Dim ListViewStudents As ListViewItem
        For Each ListViewStudents In lsvFemaleStudents.Items
            MessageBox.Show(lsvFemaleStudents.Columns.Count)
            If CurrentSelectedSession.SubItems(1).Text = "Afternoon" Then
                If ListViewStudents.Checked = True Then
                    ListViewStudents.SubItems(5).Text = "Present"
                Else
                    lsvFemaleStudents.SelectedItems(0).SubItems(5).Text = "Present"
                    ListViewStudents.SubItems(5).Text = "Absent"
                End If
            Else
                If CurrentSelectedSession.SubItems(1).Text = "Morning" Then
                    If ListViewStudents.Checked = True Then
                        ListViewStudents.SubItems(4).Text = "Present"
                    Else
                        ListViewStudents.SubItems(4).Text = "Absent"
                    End If
                End If
            End If
        Next
        lsvFemaleStudents.Refresh()

Use IsNothing to test the available of an object. Also use Count property to get the count of subitems.

IF IsNothing(ListViewStudents) Then

 Else

 End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.